Ceejay
Ceejay

Reputation: 7297

How to render view in rails

i am using rails for my application.i have generated scaffold for crud operation. i have scaffold for product_lists. i have page called user_dashboard.html.erb here i want to render pages from product_lists.

i have user_dashboard.html.erb page in pages/ directory..i want to render index.html page from product_lists directory inside user_dashboard.html.erb. i have tried using render.. but its showing error here is what i have tried

<div class="panel-body">      
        <%= render 'product_lists' %>
</div>

error:

ActionView::MissingTemplate in Pages#user_dashboard

How can i solve this error and why is this raised?

Upvotes: 1

Views: 66

Answers (2)

Brad Werth
Brad Werth

Reputation: 17647

It is not a partial (starts with underscore), so you need render template. You also need the full path of the template, from the view directory:

<%= render template: 'product_lists/index' %>

Upvotes: 4

Tim Kretschmer
Tim Kretschmer

Reputation: 2280

if its not within the same folder you need to explicit tell the path. the error message is showing where rails is looking for.

<%= render "product_lists/index" %>

Upvotes: 0

Related Questions