Monday, April 16, 2012

Rails 3 render layout in action causes error with Twitter Bootstrap

Im using twitter bootstrap for design. I want to use a different template for a specific action

def view
render :layout => 'single'
@movie = Movie.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @movie }

As soon as i add in the render layout to the action I get this error message

undefined method `model_name' for NilClass:Class

Extracted source (around line #2):

1: <%- model_class = @movie.class -%>
2: <h1><%=t '.title', :default => model_class.model_name.human %></h1>
4: <p>
5: <strong><%= model_class.human_attribute_name(:title) %>:</strong><br>

If I take the render away the page will load just fine.

No comments:

Post a Comment