Reputation: 323
I am trying to render a partial on a collection with <%= render @posts %>
which returns the error:
Missing partial posts/post with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}
However it works if i use <%= render :partial => 'post', :collection => @posts %>
I have _post.html.erb
in the same folder which uses post
variable (from posts)
Why would the former example way of rendering a partial on a collection not work, but the latter example does work?
EDIT: I should specify I'm using Rails 3.2.1
Upvotes: 1
Views: 806
Reputation: 4217
The default of to_partial_path
for your objects is always scoped under a view folder for the class, so your partial must be in the posts
view folder.
When you use the form render :partial => 'post'
it looks in the folder of the controller you are currently under.
I suspect that you are not working in the PostsController
view folder, which would explain the behavior you are seeing. If you are working in the posts
view folder, then something else must be going on so if you could provide more detail that would help diagnose it further
Upvotes: 3