On Mar 13, 1:28 pm, Erwin <yves_duf...@mac.com> wrote:
> to avoid being confused with 'object' litteral .. I modified the test
> code as following :
>
> #lockers
>         %table#items
>                 = render :partial => 'item',  :collection => ['foo', 'bar', 
> 'baz']
>
> and the _item  partial
>
> = content_tag_for(:tr, item) do
>         %td= item
>
> this time , the error is :   undefined method `model_name' for
> String:Class
>
> I believe there is something wrong with the content_tag_for...
>

Oops, hadn't spotted that you were using content_tag for as opposed to
content_tag. The entire point of content_tag_for is that you give it
an activemodel like object and it will set the dom id & css class
appropriately.
If you don't have such objects (eg you have strings instead), then
don't use content_tag_for. content_tag might be what you're looking
for.

Fred


> On 13 mar, 13:34, Frederick Cheung <frederick.che...@gmail.com> wrote:
>
>
>
> > On Mar 13, 11:42 am, Erwin <yves_duf...@mac.com> wrote:
>
> > > In the controller , I am passing an Array as a collection
> > >  @objects = ["item1", "item2", "item3", "item4"]
>
> > > in the view I wrote
> > > %table#objects
> > >     = render :partial => 'object',  :collection => @objects
>
> > > and in my partial  _object.html
> > > = content_tag_for(:tr, @object) do
> > >         %td= @object
> > >         %td= link_to........
>
> > > but I got an error :  undefined method `model_name' for NilClass:Class
> > > for the #object in the content_tag
>
> > > @object is not not a class..... (yet)  I  just to want to test on an
> > > Array of string ....  anyway of doing such thing ?
>
> > @object isn't set - you should be using object (since that's what
> > render will be filling with the items from @objects
>
> > Fred
>
> > > thanks for your feedback

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to