Link_to(image_tag ...) works locally but breaks on Heroku deployment
pretty simple bit of ruby code is working fine when run on localhost but breaks when pushed up to heroku. H开发者_如何学JAVAere it is:
<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>
And here is the error in Heroku Logs referring to the link_to line above:
ActionView::Template::Error (wrong number of arguments (2 for 1))...
What gives? Any ideas?
Thanks!
When you have multiple encapsulated method calls, Ruby needs the proper parentheses so it knows which arguments go with which method. You can have the first method call without parentheses (h
in this case), but the rest are needed.
<%=h link_to(image_tag(small_avatar_url(r.user), :class => "u_profile_img_small", :title => r.user.name), r.user) %>
I think the parentheses are throwing off your link_to
call. Try tightening it up like this:
<%=h link_to(image_tag(small_avatar_url(r.user), :class => "u_profile_img_small", :title => r.user.name), r.user) %>
Note: You may not want to be using <%=h
as that will escape the <
and >
in your generated link.
精彩评论