It looks from your code as if you’re returning a list of user galleries
rather than a single one, so the list you get won’t have a photos
method.
Does your code work if you change the third line in your method to
well if you want all the primary photos just use my suggested
named_scope. then you can ask: @all_primary_photos = Photo.all.primary # or just Photo.primary @all_galleries = Gallery.all
no loop needed. but if you want to loop, you can do that with @all_galleries.each do |gallery|
# gallery.photos
end
It looks from your code as if you’re returning a list of user galleries
rather than a single one, so the list you get won’t have a photos
method.
Does your code work if you change the third line in your method to
@gallery = @user.galleries.first
Yes, thats the error.
Now it is working but just for the first one.
Is there a way to loop all of the users galleries?
Thank you.
P.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.