Ruby on Rails
Sunday, November 22, 2015
although the object's not null, the syntax you gave me "category.first.name" doesn't work
On Sunday, November 22, 2015 at 3:44:22 AM UTC-5, Arvind Vyas wrote:
-- "undefined method `name' for 0:Fixnum"On Sunday, November 22, 2015 at 3:44:22 AM UTC-5, Arvind Vyas wrote:
As I told you in earlier check what object you are getting and fetch the name accordingly.For example if I got category object is like [#<Category id: 1, name: "2012-08-31 20:34:15">]so in simplest way I can write category.first.name but in this case you have to check cateroy object should not nil.Also you can check this example it has also same issue as you are looking form http://stackoverflow.com/questions/12124941/undefined- method-name-for-array-in- activeadmin-row Thanks and Regards,
Arvind Vyas
Ruby On Rails Developer
Mob ; 8511289155On Sun, Nov 22, 2015 at 12:54 PM, fugee ohu <fuge...@gmail.com> wrote:so how do i dereference the array in the view to display the name--
On Sunday, November 22, 2015 at 1:22:17 AM UTC-5, Arvind Vyas wrote:category object is coming as an array so first check thatThanks and Regards,
Arvind Vyas
Ruby On Rails Developer
Mob ; 8511289155On Sun, Nov 22, 2015 at 2:54 AM, fugee ohu <fuge...@gmail.com> wrote:<h2>Categories</h2>--
<%= @categories.group_by(&:parent_id).each do |category| %>
<%= category.name %><br>
<% end %>
This code results in ActionController returningundefined 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-ta...@googlegroups.com .
To post to this group, send email to rubyonra...@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
For more options, visit https://groups.google.com/d/optout .
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-ta...@googlegroups.com .
To post to this group, send email to rubyonra...@googlegroups.com .
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/ .84648581-9e36-4d08-97ca- f0960acd44ed%40googlegroups. com
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/845c3185-d24d-4163-bcd6-e59cc9f2c15c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment