mar*_*ion 2 ruby-on-rails ruby-on-rails-3
基本上我想要做的是检查方法是否在对象上返回true,如果是,则将特定类应用于图像.
如果没有,那就什么都不做.
所以我尝试了这个:
<%= image_tag(upload.image.url, if upload.upvoted? :class => 'upvoted') %>
Run Code Online (Sandbox Code Playgroud)
但这是我得到的错误:
/app/views/stages/compare.html.erb:29: syntax error, unexpected ')', expecting keyword_then or ';' or '\n'
...d.upvoted? :class => 'upvoted') );@output_buffer.safe_concat...
... ^
/app/views/stages/compare.html.erb:31: syntax error, unexpected keyword_end, expecting ')'
'); end
^
/app/views/stages/compare.html.erb:63: syntax error, unexpected keyword_ensure, expecting ')'
/app/views/stages/compare.html.erb:65: syntax error, unexpected keyword_end, expecting ')'
Run Code Online (Sandbox Code Playgroud)
<%= image_tag(upload.image.url, :class => upload.upvoted? ? 'upvoted' : nil) %>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2263 次 |
| 最近记录: |