Rendering partial from another folder from another partial in Rails 3

aetaur picture aetaur · Aug 19, 2011 · Viewed 23.5k times · Source

For example: I'm have two models: Task and List. Task belongs_to List. I'm render lists/_form.html.erb partial within lists/show.html.erb view. Now I need to render tasks/_fields.html.erb partial within lists/_form.html.erb partial:

<%= render 'tasks/fields' %>

But I get an error ActionView::MissingTemplate

If I try to render tasks/_fields.html.erb within lists/_form.html.erb, everything works.

I see two bad ways to solve this problem:

Is there a good way?

Answer

Arun Kumar Arjunan picture Arun Kumar Arjunan · Aug 19, 2011

Try this:

<%= render :partial => 'tasks/fields' %>