0

I 'm working on a tumbnail that's gonna contain all the friend gravatar with a link to each friend profile .I got every thing working till i add this part. , other_user_page_path(friend.username) the error is

undefined method `symbolize_keys!' for "/reie":String

here is the entire code

<% current_user.friends_of.each do |friend| %>
       <%=  link_to image_tag (friend.gravatar_url(:size => 30)) , other_user_page_path(friend.username)%>
    <% end %>
Simone Carletti
  • 173,507
  • 49
  • 363
  • 364
skip87
  • 529
  • 1
  • 7
  • 27
  • You pass a string where hash is expected. It's hard to tell more using information you provided – Sergio Tulentsev Dec 11 '12 at 19:55
  • Yes, "image_tag " is looked at as a method without arguments in 1.9.x (atleast in 1.9.3) , but works like a method with arguments in 1.8.7. I found this in a code and removing the space after the image_tag works well. – Sairam Feb 26 '14 at 15:48

3 Answers3

1

The error is here

  <%=  link_to image_tag (friend.gravatar_url(:size => 30))
 , other_user_page_path(friend.username)%>

remove the space after image_tag. Change it to like this.

 <%=  link_to image_tag(friend.gravatar_url(:size => 30))
 , other_user_page_path(friend.username)%>

This should fix your problem.

Prabhakar
  • 6,458
  • 2
  • 40
  • 51
  • this explanation feels silly, but it remains valid; the two spaces are what throws the engine off. – Jerome Jan 10 '18 at 12:23
0
<% current_user.friends_of.each do |friend| %>
       <%= link_to(image_tag (friend.gravatar_url(:size => 30)) , other_user_page_path(friend.username)) %>
<% end %>
Magicmarkker
  • 1,063
  • 7
  • 25
  • Don't know why but i got it working with this link_to `<%= image_tag(friend.gravatar_url(:size => 30)) , other_user_page_path(friend.username) %>` is rails space sensitive ? – skip87 Dec 11 '12 at 20:05
  • Not from what I can tell, but it's best to have only one space after <%=. It also is easier to use link_to() with parenthesis when you're calling a method inside both of its parameters, from my experience anyway. – Magicmarkker Dec 11 '12 at 20:14
0

Try

<% current_user.friends_of.each do |friend| %>
   <%=  link_to other_user_page_path(friend.username) do %>
     <%= image_tag(friend.gravatar_url(:size => 30)) %>
   <% end %>   
<% end %>
cryo28
  • 1,127
  • 6
  • 9
  • Don't know why but i got it working with this `<%= link_to image_tag(friend.gravatar_url(:size => 30)) , other_user_page_path(friend.username) %>` is rails space sensitive ? – skip87 Dec 11 '12 at 20:09
  • It is not about spaces and not about rails. It is all about ruby and parenthesis. Ruby allows omitting parenthesis in method calls. However it is always a good idea not to omit them if you evaluate some expression to get some argument value. If you still omit parenthesis you should be aware of the ruby parsing rules: you need to understand what expression will become an argument of which method. By adding parenthesis you just make your code a bit cleaner. – cryo28 Dec 11 '12 at 20:25