How do I use the variable on my show page?

Hi…

@polloption_sum = Voted.where(polloption_id: 42).count

I need to fix this, i temporarily added a dummy variable ‘42’ to count my records, but I want to get this from the show page where I loop thru each poll_option.
I thought I could use

@polloption_sum = Voted.where(polloption_id: :polloption.id).count
but it didn’t. (I must have the wrong syntax).

I get undefined method `id’ for :polloption:Symbol

You are calling id on a symbol not a variable or object. Remove the colon before polloption

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs