Ruby on Rails Sunday, November 22, 2015

Arvind Vyas <arvindvyas07@gmail.com> writes:

> category object is coming as an array so first check that

With `group_by`, it's actually a hash of the counts for each grouping
and the group collection. Thus each category is `{ 10 => [.. array of
category objects ..]}`

http://ruby-doc.org/core-2.2.3/Enumerable.html#method-i-group_by

>
> Thanks and Regards,
>
> Arvind Vyas
> Ruby On Rails Developer
> Mob ; 8511289155
>
> On Sun, Nov 22, 2015 at 2:54 AM, fugee ohu <fugee279@gmail.com> wrote:
>
>> <h2>Categories</h2>
>> <%= @categories.group_by(&:parent_id).each do |category| %>
>> <%= category.name %><br>
>> <% end %>
>>
>> This code results in ActionController returning
>>
>> undefined method `name' for #<Array:0xb48bf628>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ruby on Rails: Talk" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to rubyonrails-talk+unsubscribe@googlegroups.com.
>> To post to this group, send email to rubyonrails-talk@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/rubyonrails-talk/0fe07e54-776d-45a3-812d-5aa6247d21dc%40googlegroups.com
>> <https://groups.google.com/d/msgid/rubyonrails-talk/0fe07e54-776d-45a3-812d-5aa6247d21dc%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>

--
Tamara Temple
tamouse@gmail.com
http://www.tamouse.org

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/m2y4dqrtpo.fsf%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment