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 / Controller / Aventus_controller.rb model / event.rb model / user.rb model / attendance. RB I think you are having trouble finding the presenter .
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
class user & lt; ActiveRecord :: Base is has_many: The event has has_many: attendees ,: dependent = & gt; : Has_many is destroyed: events, via = & gt; : Attendees
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
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
Post a Comment