Users can vote on posts, so I set a many to many relationship in rails:
users have many votes
posts have many votes
posts have many users through votes
users have many posts through votes
Is there a more elegant way to create a new vote than this:
user.votes.create(:post_id => post.id).save
? thanks
There is at least a “standard” way. I assume this is coming in from a form somewhere. So just pass in params like so: