I am iterating through a hash and displaying the values as radio buttons. The hash looks like this:
{
1=>["a", "b"],
2=>["c"],
3=>["a", "d", "f", "g"],
4=>["q"] ..
}
After selecting the values, the parameters become:
{ "commit"=>"vote", "authenticity_token"=>"db863239855c9f73b9ae54c37f6b92c858acb56f", "1"=>"a", "2"=>"c", "3"=>"d", "4"=>"q"}
How can I access these values (POST data) in the update method of the controller in order to update the count field? I have tried like this.
@votings = Voting.find(:all, :conditions => {params[:k]=>params[:val]})
@votings.each do |voting|
voting.update_attribute('vote_count',
voting.vote_count+1)
end
But gives this error:
You have a nil object when you didn't expect it! The error occurred while evaluating nil.each..
Can anybody tell where I went wrong?