如何将类添加到 image_tag Rails 帮助程序
我有以下代码:
<%= image_tag iterator.image.url(:small), :class => "img_preview" %>
但渲染的 HTML 显示:
<img src="/actives/hotels/13/small/clean_wave.jpg?1317675452" alt="Clean_wave">
为什么“class”属性不存在?
谢谢你!
I have the following code:
<%= image_tag iterator.image.url(:small), :class => "img_preview" %>
But the rendered HTML shows:
<img src="/actives/hotels/13/small/clean_wave.jpg?1317675452" alt="Clean_wave">
Why the "class" attribute isn't there?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的类必须分配在括号内,才能用作传递的选项的一部分。尝试:
Your class has to be assigned inside of the brackets to be used as part of the options being passed through. Try:
对于像我这样的新手,这里有一个带有较新的 Rails 语法的更清晰的版本:
For newbies like myself, heres a cleaner version with the newer rails syntax: