Forum: Ruby on Rails Database table name in array?

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.
Ead43bcb0202410540a6a7cee5955d46?d=identicon&s=25 Fresh Mix (giga)
on 2009-01-30 18:28
Is it possible to do something like this?

tables = Array[ "Xxx", "Yyy", "Zzz"]

for table in tables
  results = table.find(:all, :conditions => [".....
end
5f94b9b346c2aa648a80bc259978e5bc?d=identicon&s=25 Colin Law (Guest)
on 2009-01-30 18:32
(Received via mailing list)
I would try it and see. It will either work or not.

2009/1/30 James Bond <rails-mailing-list@andreas-s.net>
D188e591eac11021329b8821a5f954c7?d=identicon&s=25 Ar Chron (railsdog)
on 2009-01-30 19:24
James Bond wrote:
> Is it possible to do something like this?
>
> tables = Array[ "Xxx", "Yyy", "Zzz"]
>
> for table in tables
    @records = table.camelcase.constantize.find(:all, blah blah blah)
> end
This topic is locked and can not be replied to.