When a Partial lies in the main layout

Help :frowning: in my controller Ad layout i have a ‘render partial’
that partial will iterate through an array of data from the db, ok
basic.

but where should i put this line in my Ad controller?
@ad = Ad.find_all_by_user_id(sessions[:user])
( since there’s no particular method, which would’ve been basic and
easy.)

i’ve tried putting it under the index method, and it works except for
the first time the page is called, there is a nil…
i’ve tried putting it under ‘initalize’, and that messes the session up.
and also tried point blank under the class, and no hope…

has_many_questions wrote:

Oops, it’s in dave’s rails app which i’m following now (Creating a cart
section of the depot app)

has_many_questions wrote:

Help :frowning: in my controller Ad layout i have a ‘render partial’
that partial will iterate through an array of data from the db, ok
basic.

but where should i put this line in my Ad controller?
@ad = Ad.find_all_by_user_id(sessions[:user])
( since there’s no particular method, which would’ve been basic and
easy.)

i’ve tried putting it under the index method, and it works except for
the first time the page is called, there is a nil…
i’ve tried putting it under ‘initalize’, and that messes the session up.
and also tried point blank under the class, and no hope…

Glad you found the answer. Just chimed in to say that your “handle” on
this list is priceless. It really captures the “dances_with_wolves”
feel of the Rails naming conventions. Well done.

jp

Oops, it’s in dave’s rails app which i’m following now (Creating a cart
section of the depot app)

has_many_questions wrote:

Help :frowning: in my controller Ad layout i have a ‘render partial’
that partial will iterate through an array of data from the db, ok
basic.

but where should i put this line in my Ad controller?
@ad = Ad.find_all_by_user_id(sessions[:user])
( since there’s no particular method, which would’ve been basic and
easy.)

i’ve tried putting it under the index method, and it works except for
the first time the page is called, there is a nil…
i’ve tried putting it under ‘initalize’, and that messes the session up.
and also tried point blank under the class, and no hope…

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs