undefined method `symbolize_keys' for

108 views
Skip to first unread message

Dave Castellano

unread,
Nov 10, 2014, 3:05:36 PM11/10/14
to rubyonra...@googlegroups.com
Hi,

I am getting the error:
undefined method `symbolize_keys' for "/contents/index_books/13":String

for the following:

<%= link_to(image_tag src= asset_path("#{subject.icon}" + '.png'),
index_books_path(:subject_id => subject.id)) %>

I understand that a hash is expected and a string is being found, but
not sure why. Is my syntax incorrect?

Thanks,

Dave Castellano

--
Posted via http://www.ruby-forum.com/.

Dave Aronson

unread,
Nov 10, 2014, 4:02:42 PM11/10/14
to rubyonra...@googlegroups.com
On Monday, November 10, 2014, Dave Castellano <li...@ruby-forum.com> wrote:

I am getting the error:
undefined method `symbolize_keys' for "/contents/index_books/13":String

for the following:

 <%= link_to(image_tag src= asset_path("#{subject.icon}" + '.png'),
index_books_path(:subject_id => subject.id)) %>

Try fixing the "src=" bit.  That's HTML, not Ruby.


--
Sent from Gmail Mobile; please excuse top posting, typos, etc. :-(

Dave Castellano

unread,
Nov 10, 2014, 4:18:10 PM11/10/14
to rubyonra...@googlegroups.com
Dave Aronson wrote in post #1162130:
>
>
> Try fixing the "src=" bit. That's HTML, not Ruby.
>
<%= link_to(image_tag asset_path("#{subject.icon}" + '.png'),
index_books_path(:subject_id => subject.id)) %> still throws same error.

<%= image_tag asset_path("#{subject.icon}" + '.png') %> works fine so I
am assuming its the link_to and not the image_tag.

Dave

Colin Law

unread,
Nov 10, 2014, 4:27:54 PM11/10/14
to rubyonra...@googlegroups.com
On 10 November 2014 21:17, Dave Castellano <li...@ruby-forum.com> wrote:
> Dave Aronson wrote in post #1162130:
>>
>>
>> Try fixing the "src=" bit. That's HTML, not Ruby.
>>
> <%= link_to(image_tag asset_path("#{subject.icon}" + '.png'),
> index_books_path(:subject_id => subject.id)) %> still throws same error.

I suspect you are passing index_books_path() as a second parameter to image_tag.

>
> <%= image_tag asset_path("#{subject.icon}" + '.png') %> works fine so I
> am assuming its the link_to and not the image_tag.

A wrong assumption I think

Colin

Rob Biedenharn

unread,
Nov 10, 2014, 4:31:26 PM11/10/14
to rubyonra...@googlegroups.com

On 2014-Nov-10, at 16:17 , Dave Castellano <li...@ruby-forum.com> wrote:

> Dave Aronson wrote in post #1162130:
>>
>>
>> Try fixing the "src=" bit. That's HTML, not Ruby.
>>
> <%= link_to(image_tag asset_path("#{subject.icon}" + '.png'),
> index_books_path(:subject_id => subject.id)) %> still throws same error.

Try it without attempting to elide the parentheses around the single argument of image_tag:

<%= link_to(image_tag(
asset_path("#{subject.icon}" + '.png')
),
index_books_path(:subject_id => subject.id)
) %>

Your version is almost certainly being interpreted as if you had put:

<%= link_to(image_tag(asset_path("#{subject.icon}" + '.png'),
index_books_path(:subject_id => subject.id)
)
) %>

> <%= image_tag asset_path("#{subject.icon}" + '.png') %> works fine so I
> am assuming its the link_to and not the image_tag.
>
> Dave
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/a794f86cd2dbf057d8bca2e0fae6993d%40ruby-forum.com.
> For more options, visit https://groups.google.com/d/optout.

Dave Castellano

unread,
Nov 10, 2014, 8:31:54 PM11/10/14
to rubyonra...@googlegroups.com
OK, Got it!! Thanks for the help!
Reply all
Reply to author
Forward
0 new messages