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.
photo m. (Guest)
on 2007-01-31 03: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!
Matt J. (Guest)
on 2007-01-31 03: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 J. <removed_email_address@domain.invalid> wrote:
>
>
> Thanks!
>
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>


--
Matt J.
removed_email_address@domain.invalid
President/Technical Director, Acme Art Company (acmeartco.org)
photo m. (Guest)
on 2007-01-31 03:41
Well Matt J., 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 J. 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 J. <removed_email_address@domain.invalid> wrote:
>>
>>
>> Thanks!
>>
>> --
>> Posted via http://www.ruby-forum.com/.
>>
>> >
>>
>
>
> --
> Matt J.
> removed_email_address@domain.invalid
> President/Technical Director, Acme Art Company (acmeartco.org)
This topic is locked and can not be replied to.