I''m having trouble figuring out how to iterate on entries from a table
that is not the master table where I have my read_scope defined.
Example:
Say I want to list all of the birds that exist in all of the cages
within a certain pet store. I have the read_scope defined and working
elsewhere that will limit the scope of my query to just one pet store.
This is important to note, because the petstore_id is only available in
the ''cages'' table, not in the birds table. So, in order to
ensure my
read_scope lists only the birds from the one pet store, I''m pretty sure
that I have to setup my read_scope as follows, then query for all cages
and include the related birds.
Cage.with_scope(read_scope Cage.table_name) do
@cages = Cage.paginate(
:include => :birds
)
end
Now, it is in the list view where I am having my problem. I can''t get
the right syntax of how to iterate through all of the birds in a single
list. Here are a couple of things I have tried
@cages.each do { |b|
b.bird.each {}
}
or
@cages.bird.each do |b|
...and many others. Just so it is clear, I can''t query directly for
the
bird because there is no petstore_id and thus the read_scope setup
throughout the application does not work. Can anyone suggest a syntax
that will work?
Thanks,
Brad
--
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---