ruby - Rails has_many :through association. Remove an association with a link? -


I have an event model and a user model has been joined through an interactive model. I have come to know how to "participate" as a certified user but what I can not understand is a good way to "withdraw" from an event. I'm sure this is something that I'm missing, but what's the better way to enter stack overflow instead of just asking something? Oh, I am searching for railways and for a few hours ...

Thank you!

view / events / show.html.erb

   & Lt; Ul & gt; & Amp; For attendee & lt;% event.users% & gt; & Lt;% if attendance. Username == Current_Uzwer.open% & gt; & Lt; Li & gt; & Lt; Strong & gt; & Lt;% = Presence Username% & gt; & Lt; / Strong & gt; & Lt;% = link_to 'Undo event', retract _event_path (@ event.id) ,: method = & gt; : Post, class = & gt; 'BTN BTN-Danger'% & gt; & Lt;% = link_to 'deleted', @eddedie, confirm: 'are you sure?', Method :: delete, class = & gt; 'BTN BTN-Danger'% & gt; & Lt; / Li & gt; & Lt;% else% & gt; & Lt; Li & gt; & Lt;% = Presence Username% & gt; & Lt; / Li & gt; & Lt;% end% & gt; & Lt;% end% & gt; & Lt; / Ul & gt; & Lt; / P & gt;   

/ Controller / Aventus_controller.rb

  def present @ event = event.fund (param [: id]) current_user .events & lt; & Lt; @event redirect_to @event, notice: 'You have promised to participate in this event.' Undo the end DEF # I can not take it to work on @event_to @event, notice: 'You are no longer involved in this incident.' End   

model / event.rb

  class event & lt; ActiveRecord :: Base attr_accessible: Name ,: location is_to: user has_many: attendees ,: dependent = & gt; : Has has_many: users ,: through = & gt; : Present   

model / user.rb

  class user & lt; ActiveRecord :: Base is has_many: The event has has_many: attendees ,: dependent = & gt; : Has_many is destroyed: events, via = & gt; : Attendees   

model / attendance. RB

  Classroom presence & lt; ActiveRecord :: Base is_to: event is_to: user attr_accessible: user_id ,: event_id # Make sure a user can not be included in the same event more than once at a time. Valid: event_id,: Specification = & gt; {: Area = & gt; : User_id} End    

I think you are having trouble finding the presenter .

  def event event = Event.find (params [: id]) attendee = Attendee.find_by_user_id_and_event_id (current_user.id, event.id) if attendee.blank? In the # handles case where no matching attendance record is present. To redirect the event, notice: 'You are no longer involved in this incident.' End    

Comments