My partial is not where rails expects it to be (nested partials)

Posted by new2ruby on Stack Overflow See other posts from Stack Overflow or by new2ruby
Published on 2012-10-05T15:30:19Z Indexed on 2012/10/05 15:37 UTC
Read the original article Hit count: 197

Filed under:
|

I have a model Submissions which has many Performers. I have a partial for showing an individual submissions (app/views/submissions/_submission.html.erb):

<div>
  Show stuff relating to @submission
  ...
  <%= render @performers %>
</div>  

and a partial for showing performers (app/views/performers/_performer.html.erb):

<%= div_for performer do %>
  <%= performer.name %>
<% end %>

This works fine from (app/views/submissions/show.html.erb):

<%= render @submission %>

But I want to use this from a different namespace too (app/views/curator/submissions/show.html.erb). But I get this error:

Missing partial curator/submissions/submission with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}. Searched in:
  * "/Users/ircmullaney/RubyCode/cif/app/views"
  * "/Users/ircmullaney/.rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/gems/devise-2.1.2/app/views"

I can fix this by changing the render to this:

<%= render 'submissions/submission' %>

But, then the nested partial fails:

Missing partial curator/performers/performer with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}. Searched in:
  * "/Users/ircmullaney/RubyCode/cif/app/views"
  * "/Users/ircmullaney/.rvm/gems/ruby-1.9.3-p194@rails3tutorial2ndEd/gems/devise-2.1.2/app/views"

This doesn't work:

<%= render 'performers/performer' %>

because of the div_for:

undefined method `model_name' for NilClass:Class

Any ideas how I should do this?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about partial