The same question has been asked many times, but I am unable to find a solution that works for me.
I have three models, posts, users, and picture (paperclip).
I use restful_authentication and set it up so that each user sees only his/her post in posts/index. I've also given him the ability to upload a profile picture.
My question is how do I take the picture/index and show it in post/index. I want to show a thumbnail on top of the post/index page, followed by the posts.
I've used partials, but I get the error
NoMethodError in Posts#index
Showing app/views/us/_picture.html.erb where line #1 raised:
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each
Extracted source (around line #1):
1: <% for u in @us %>
2: <tr>
3: <td><%= image_tag u.picture.url(:thumb) %></td>
4: <td><%=h u.name %></td>
I see what it's trying to do, how do I solve it so that it just shows the uploaded picture.
Thanks for your help.