Undefined `render 'method!

I just create a simple new action in rails, but when I view it in a browser, I get this error:

undefined method `render' for #<Template:0x9e9993c> 

new method:

  def new @template = Template.new end 

I have new.html.erb in the folder! What is the problem?

+7
ruby-on-rails
source share
1 answer

The problem is that you are trying to assign a custom object to an @template instance variable, but @template is an internal variable that must contain an instance of the Rails template for the current action.

Use a different variable name

 def new @tpl = Template.new end 
+12
source share

All Articles