views:

458

answers:

1

i am just creating a simple new action in rails, but when i view it in browser i get this error :

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

the new method is :

  def new
    @template = Template.new
  end

i have new.html.erb in the folder ! whats the problem ?

+8  A: 

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

Use a different variable name

def new
  @tpl = Template.new
end
Simone Carletti
Thanks ! I didn't know that :)
Datis