Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

undefined method `render' !

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 ?

like image 279
datisdesign Avatar asked Dec 09 '09 15:12

datisdesign


1 Answers

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
like image 118
Simone Carletti Avatar answered Oct 27 '22 17:10

Simone Carletti