Sunday, March 13, 2011

[Rails] Re: undefined method `model_name in partial .. passing an Array as a collection

Thanks fred.. I tried with object but same error.. it seems
model_name_from_record_or_class is needed when using collection
I may have to change the partial rendering ... ?

-- trace
activemodel (3.0.4) lib/active_model/naming.rb:94:in
`model_name_from_record_or_class'
activemodel (3.0.4) lib/active_model/naming.rb:81:in `singular'
actionpack (3.0.4) lib/action_controller/record_identifier.rb:49:in
`dom_class'
actionpack (3.0.4) lib/action_view/helpers/record_tag_helper.rb:58:in
`content_tag_for'
app/views/admin/remote_lockers/_object.html.haml:1:in
`_app_views_admin_remote_lockers__object_html_haml__3334574884651529235_2179828200_2175116202532159367'
actionpack (3.0.4) lib/action_view/template.rb:135:in `block in
render'
activesupport (3.0.4) lib/active_support/notifications.rb:54:in
`instrument'
actionpack (3.0.4) lib/action_view/template.rb:127:in `render'
actionpack (3.0.4) lib/action_view/render/partials.rb:300:in `block in
collection_with_template'
actionpack (3.0.4) lib/action_view/render/partials.rb:297:in `each'
actionpack (3.0.4) lib/action_view/render/partials.rb:297:in
`collection_with_template'
actionpack (3.0.4) lib/action_view/render/partials.rb:280:in
`render_collection'


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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate