i had the following error while trying to implement Collection _select
in making a drop down of items in two models

You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.map

my code in the views is as follows:

<%= collection_select("category", "category_id",@categorys, "id",
"category_type") %>
I need guidance on how to properly do this, thanks for the support
yesterday.

--
Posted via http://www.ruby-forum.com/.

--
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.

Search Discussions

  • Colin Law at Nov 17, 2011 at 9:36 am

    On 17 November 2011 09:18, gbolahan a. wrote:
    i had the following error while trying to implement Collection _select
    in making a drop down of items in two models

    You have a nil object when you didn't expect it!
    You might have expected an instance of Array.
    The error occurred while evaluating nil.map

    my code in the  views is as follows:

    <%= collection_select("category", "category_id",@categorys, "id",
    The error probably means that @categorys is nil, did you mean
    @categories possibly?

    Colin
    "category_type") %>
    I need guidance on how to properly do this, thanks for the support
    yesterday.
    --
    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.
  • Gbolahan a. at Nov 17, 2011 at 1:11 pm
    i have modified my code as follows:

    <%= collection_select(:category, :id, @categories, :id, :category_type,
    options ={:prompt => "-Select a Category"}, :class =>"category") %>

    i Hav also modified the definition in my controllers as follows:

    @categories = category.find(:all)

    You have a nil object when you didn't expect it!
    You might have expected an instance of Array.
    The error occurred while evaluating nil.map
    seems there something i dont get

    --
    Posted via http://www.ruby-forum.com/.

    --
    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.
  • Peter De Berdt at Nov 17, 2011 at 1:19 pm

    On 17 Nov 2011, at 14:11, gbolahan a. wrote:

    i Hav also modified the definition in my controllers as follows:

    @categories = category.find(:all)
    Classes should have a capital:

    Category.find(:all)

    and you could even bring this down to:

    Category.all


    Best regards

    Peter De Berdt

    --
    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.
  • Colin Law at Nov 17, 2011 at 1:20 pm

    On 17 November 2011 13:11, gbolahan a. wrote:
    i have modified my code as follows:

    <%= collection_select(:category, :id, @categories, :id, :category_type,
    options ={:prompt => "-Select a Category"}, :class =>"category") %>

    i Hav also modified the definition in my controllers as follows:

    @categories = category.find(:all)
    That should be Category.find(:all)
    You have a nil object when you didn't expect it!
    You might have expected an instance of Array.
    The error occurred while evaluating nil.map
    seems there something i dont get
    You have not said where that error occurs, but wherever it is
    something is nil. Have a look at the Rails Guide on Debugging, that
    will show you how to use ruby-debug to break into code, inspect data
    and follow the flow. Then when you get this sort of error you can put
    in breakpoints and check each of the variables to find which one is
    nil.

    Colin
    --
    Posted via http://www.ruby-forum.com/.

    --
    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.


    --
    gplus.to/clanlaw

    --
    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.
  • Gbolahan a. at Nov 17, 2011 at 1:56 pm
    i have modified my code as follows:

    <%= collection_select(:category, :id, @categories, :id, :category_type,
    options ={:prompt => "-Select a Category"}, :class =>"category") %>

    i Hav also modified the definition in my controllers as follows:

    @categories = category.find(:all)

    but it still gives me the following error

    You have a nil object when you didn't expect it!
    You might have expected an instance of Array.
    The error occurred while evaluating nil.map
    seems there something i dont get

    --
    Posted via http://www.ruby-forum.com/.

    --
    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.
  • Colin Law at Nov 17, 2011 at 3:27 pm

    On 17 November 2011 13:56, gbolahan a. wrote:
    i have modified my code as follows:

    <%= collection_select(:category, :id, @categories, :id, :category_type,
    options ={:prompt => "-Select a Category"}, :class =>"category") %>

    i Hav also modified the definition in my controllers as follows:

    @categories = category.find(:all)

    but it still gives me the following error
    You have not said, but I presume that you mean that it still gives you
    the error with Category.find. How did you get on with ruby-debug?

    Colin
    You have a nil object when you didn't expect it!
    You might have expected an instance of Array.
    The error occurred while evaluating nil.map
    seems there something i dont get

    --
    Posted via http://www.ruby-forum.com/.

    --
    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.


    --
    gplus.to/clanlaw

    --
    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.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedNov 17, '11 at 9:19a
activeNov 17, '11 at 3:27p
posts7
users3
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2021 Grokbase