Validate uniqueness of user_id, friend_id, event_id in Rails 3 -


When a user sees an event in my app, then I compare a list of attendees to the user's Facebook friends. And store any intersections I search in an event friday table.

I need to verify the specification in 3 columns in the table because a user can have a friend who is participating in more than one event.

Any thoughts? user.rb

  has_many: event_users accepts __ nested_attributes_for: event_users,: Allow_destroy = & gt; ; True is mine: events, through => : Event_Uceres ,: Order = & gt; 'Start' has_many: event_friends accepts_nested_attributes_for: event_friends ,: allow_destroy = & gt; True   

event.rb

  is_im: event_users, dependent => : Destroys accepts_nested_attributes_for: event_users ,: allow_destroy = & gt; True: Medium: Users, By: = & gt; : Event_users have_many: event_friends,: Dependent => : Destroys accepts_nested_attributes_for: event_friends ,: allow_destroy = & gt; True   

event_user.rb

  related_ to: event is_to: user validation_natural_appress: event_id ,: scope = & gt; : User_id   

event_friend.rb

This table contains user_id, event_id and friend_id columns.

Code> valid valid_expression: friend_id ,: scope = & gt; [: User_id ,: event_id]

Comments