Forum: Ruby on Rails Help making a collection available in a view...

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Eee01a8a369b47bcb57c2b501ef0bcb7?d=identicon&s=25 photo matt (photomatt)
on 2007-01-31 02:20
I confess to being a newbie.

Here is the controller code, and I know there to be product_types that
are related to the photographer.

  def list
    photographer = Photographer.find_by_id( session[:photographer_id] )
    @productTypes = photographer.product_types
  end

And in the view....
<% for product_type in @product_types %>

Gives me 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.each


Any thoughts?

Thanks!
4858ffb014831b3741753920314adc90?d=identicon&s=25 Matt Jones (Guest)
on 2007-01-31 02:36
(Received via mailing list)
(very odd replying to a message with the same name...)
Shouldn't the second part be:

<% for product in @productTypes %>

to match the variable set in the controller?

  --mdj

On 1/30/07, Matt Jones <rails-mailing-list@andreas-s.net> wrote:
>
>
> Thanks!
>
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>


--
Matt Jones
mdj.acme@gmail.com
President/Technical Director, Acme Art Company (acmeartco.org)
Eee01a8a369b47bcb57c2b501ef0bcb7?d=identicon&s=25 photo matt (photomatt)
on 2007-01-31 02:41
Well Matt Jones, nice to meet you.  I'm sure you, like me, have met many
people in your life who share our great (and very common) name.

And thanks for catching my silly typo!

Peace,

Matt

Matt Jones wrote:
> (very odd replying to a message with the same name...)
> Shouldn't the second part be:
>
> <% for product in @productTypes %>
>
> to match the variable set in the controller?
>
>   --mdj
>
> On 1/30/07, Matt Jones <rails-mailing-list@andreas-s.net> wrote:
>>
>>
>> Thanks!
>>
>> --
>> Posted via http://www.ruby-forum.com/.
>>
>> >
>>
>
>
> --
> Matt Jones
> mdj.acme@gmail.com
> President/Technical Director, Acme Art Company (acmeartco.org)
This topic is locked and can not be replied to.