You're telling it to do exactly what you're seeing This is what creates the record you're seeing in your db. @like = @site.likes. Create!(params:like) # And now you try to assign the user.
@like. User = current_user @like. Save Try something like this instead: like = @site.likes.
Create!(params:like. Merge(:user_id => @user. Id)).
You're telling it to do exactly what you're seeing. # This is what creates the record you're seeing in your db. @like = @site.likes.
Create!(params:like) # And now you try to assign the user. @like. User = current_user @like.
Save Try something like this instead: @like = @site.likes. Create!(params:like. Merge(:user_id => @user.Id)).
Perfect. I wasn't sure how to use that merge function. – bgadoci May 20 '10 at 16:24.
I am trying to limit a user of my application to voting (liking in this case) a an answer to a question a particular number of times. I am successfully stopping the collection of the user_id but the record keeps getting created. I need for the validation to actually block the creation of the record in the likes table.
As you can see the last two votes lose the user_id but are still created. The code below will show you how I am doing this. I am trying to limit a user to voting no more than 10 times on any answer to a question.
Like Model (I spare you the reverse has_many associations but they are there).
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.