Guest User

Untitled

a guest
Aug 18th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. Rails: decide to render spefic image in view based on database entry
  2. =f.input :vote, :as => :radio, :label => "Your vote", |
  3. :collection => [["positive","/images/Thumbs-up-icon.png"],["negative","/images/Thumbs-down-icon.png"],["neutral","/images/Thumbs-neutral-icon.png"]] |
  4.  
  5. - @opinions.each do |opinion|
  6. [...]
  7. #opinion_vote
  8. = image_tag opinion.vote , {:height=>60}
  9.  
  10. def neutral?
  11. if vote == 0
  12. end
  13.  
  14. def positive?
  15. if vote == 1
  16. end
  17.  
  18. def negative?
  19. if vote == 2
  20. end
  21.  
  22. def vote_image
  23. vote.positive? ? 'positive.png' : vote.negative? ? 'negative.png' : 'neutral.png'
  24. end
Add Comment
Please, Sign In to add comment