Created
June 15, 2013 17:27
-
-
Save majornorth/5788845 to your computer and use it in GitHub Desktop.
The problem I was having was that the activity ID wasn't being received by the controller method. In params, I had [:activity] and not [:user]. Basically, the form and controller are adding a record to the join table for activities_users, submitting an ID for both activity_id and user_id. I got the help of my roommate, who is a programmer, and n…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h2>Favorite Activities</h2> | |
<ul> | |
<% User.find(current_user.id).activities.each do |a| %> | |
<li><%= a.name %> | |
<%= form_for @user, :url => removefavorite_path do |f| %> | |
<%= f.hidden_field :activity_id, :value => a.id %> | |
<%= f.submit('Remove') %> | |
<% end %> | |
</li> | |
<% end %> | |
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def addFavorite | |
Activity.find(params[:user][:activity_id]).users << current_user | |
redirect_to :back | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment