# Render partial

**URL:** <https://www.ruby-forum.com/t/render-partial/155494>\
**Category:** Rails\
**Created:** [December 12, 2008, 1:50pm UTC](https://www.ruby-forum.com/t/render-partial/155494 "2008-12-12T13:50:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![petan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c57346/32.png) [@petan](https://www.ruby-forum.com/u/petan)\
**Post date:** [December 12, 2008, 1:50pm UTC](https://www.ruby-forum.com/t/render-partial/155494/1 "2008-12-12T13:50:37Z")

</div>

Hi,

I am trying to use paperclip plugin to add images to the posts.

\<%= render :partial =\> ‘recent\_posts’, :collection =\> @posts %\>  
@posts = Post.find(:all, …, :limit =\> 5)

#\_recent\_posts.rhtml  
\<%= image\_tag recent\_posts.photo.url(:thumb) %\>

and it will end up with this error:  
“undefined method `symbolize\_keys!’ for “/posts/24?user\_id=1”:String”

Anybody knows what does this error mean?  
Thank you.

---

<div class="post-metadata">

**Author:** ![petan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c57346/32.png) [@petan](https://www.ruby-forum.com/u/petan)\
**Post date:** [December 12, 2008, 4:27pm UTC](https://www.ruby-forum.com/t/render-partial/155494/2 "2008-12-12T16:27:53Z")

</div>

I guess it is because I am not passing the post and user id. If I use  
\<%= image\_tag @post.photo.url(:thumb) %\> in my show action in posts  
controller it is working fine. But, I still dont know how to display  
photos in my collection.  
Any suggestions?

Thank you.

---

<div class="post-metadata">

**Author:** ![petan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c57346/32.png) [@petan](https://www.ruby-forum.com/u/petan)\
**Post date:** [December 19, 2008, 6:43pm UTC](https://www.ruby-forum.com/t/render-partial/155494/3 "2008-12-19T18:43:39Z")

</div>

Petan C. wrote:

> \<%= render :partial =\> ‘recent\_posts’, :collection =\> @posts %\>  
> @posts = Post.find(:all, …, :limit =\> 5)

Using the new Rails method is prettier. If Rails sees @recent\_posts  
it will automatically assume the name for the partial and pass through  
recent\_posts as a local posts variable.

\<%= render :partial =\> @recent\_posts %\>

> #\_recent\_posts.rhtml  
> \<%= image\_tag recent\_posts.photo.url(:thumb) %\>
> 
> and it will end up with this error:  
> “undefined method `symbolize\_keys!’ for "/posts/24?user\_id=1":String”

The :collection passed through is @posts. But you are referencing  
recent\_posts instead which is different.

If you go with rails iterating through the collection then the  
singularization of the plural name will create “recent\_post” from  
“@recent\_posts” and you can reference the name that way.

\<%= image\_tag recent\_post.photo.url(:thumb) %\>

If passing in @recent\_posts doesn’t make sense then you would need to  
reference through @posts with something like

post.photo.url(:thumb)

where post was created by rails for iterating over the @posts  
collection.

[ActionController::Base](http://api.rubyonrails.org/classes/ActionController/Base.html)

Bob
