How to associate posts to users if posts are already associated to another
model?
Im on rails 4. Im creating a wine review app and I have three models.
class User < ActiveRecord::Base
has_many :reviews
end
class Wine < ActiveRecord::Base
has_many :reviews
end
class Review < ActiveRecord::Base
belongs_to :user
belongs_to :wine
end
As of now I have my review form like this
<%= form_for [@wine, @review] do |f| %>
...
<% end %>
This associates the new review with the wine being reviewed. How would I
make it so when I create a new review, it associates the current_user with
the review? Thanks.
No comments:
Post a Comment