small medium large xlarge

12 Jan 2011, 00:03
Arun Srini (4 posts)

In page 145 - it goes “The render method will iterate over any collection that is passed to it. The partial template itself is simply another template file (by default in the same directory as the object being rendered and with the name of the table as the name). “ – what table is this ? The table in sqlite database? if that is the case can I render only models with tables ? Please help. I wanted to try out a sample helper so I gave <%= render => @obj1 %> I went ahead and created a obj1.rb and declared a class

class Obj1 < ActiveRecord::Base end

I creted a folder under the /app/views named obj1s/ created a file _obj1.html.erb and

  <h2> sample helper code </h2>  

is all I added. It came back with

ActionView::Template::Error (undefined method `model_name' for NilClass:Class):
    16:     <div id="side">
    17:       <div id="cart">
    18:         <%= render @cart %>
    19:         <%= render @obj1 %>
    20:       </div>
    21:       <a href="http://www...">Home</a><br />
    22:       <a href="http://www.../faq">FAQ</a><br />
  app/views/layouts/application.html.erb:19:in `_app_views_layouts_application_html_erb__453536228_91029760_420307131'

Please help me understand this. I am also trying to google on this,.

12 Jan 2011, 20:23
Sam Ruby (633 posts)

It looks like @obj1 is nil. Perhaps you meant to initialize it to ?

You must be logged in to comment