Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Rails: decide to render spefic image in view based on database entry
- =f.input :vote, :as => :radio, :label => "Your vote", |
- :collection => [["positive","/images/Thumbs-up-icon.png"],["negative","/images/Thumbs-down-icon.png"],["neutral","/images/Thumbs-neutral-icon.png"]] |
- - @opinions.each do |opinion|
- [...]
- #opinion_vote
- = image_tag opinion.vote , {:height=>60}
- def neutral?
- if vote == 0
- end
- def positive?
- if vote == 1
- end
- def negative?
- if vote == 2
- end
- def vote_image
- vote.positive? ? 'positive.png' : vote.negative? ? 'negative.png' : 'neutral.png'
- end
Add Comment
Please, Sign In to add comment