Ruby on rails 链接到(图像标签…)在本地工作,但在Heroku部署时中断
相当简单的ruby代码在localhost上运行时运行良好,但在推送到heroku时会中断。这是:Ruby on rails 链接到(图像标签…)在本地工作,但在Heroku部署时中断,ruby-on-rails,ruby,ruby-on-rails-3,heroku,Ruby On Rails,Ruby,Ruby On Rails 3,Heroku,相当简单的ruby代码在localhost上运行时运行良好,但在推送到heroku时会中断。这是: <ul> <% @regulars.each do |r| %> <li> <%=h link_to (image_tag small_avatar_url(r.user), :class => "u_profile_img_small", :title => r.user.name), r.user %>
<ul>
<% @regulars.each do |r| %>
<li>
<%=h link_to (image_tag small_avatar_url(r.user), :class => "u_profile_img_small", :title => r.user.name), r.user %>
</li>
<% end %>
</ul>
-
“u_profile_img_small”,:title=>r.user.name),r.user%>
以下是Heroku日志中的错误,该日志引用了上面的链接到行:
ActionView::Template::错误(参数数目错误(2代表1))
有什么好处?有什么想法吗
谢谢 我想括号里的内容会把你的
链接抛到呼叫上。试着像这样收紧它:
<%=h link_to(image_tag(small_avatar_url(r.user), :class => "u_profile_img_small", :title => r.user.name), r.user) %>
“u\u profile\u img\u small”,:title=>r.user.name),r.user)%>
注意:当您有多个封装的方法调用时,您可能不想使用,Ruby需要适当的括号,以便它知道哪些参数与哪个方法一起使用。第一个方法调用可以不带括号(h
,在本例中),但其余的都是必需的
“u\u profile\u img\u small”,:title=>r.user.name),r.user)%>
收紧已生效的参数。不需要移除