how to get the list of users' id

Hi,

I have a question that how to take a list of user on user table

def show_pic

@id = User.find(:all, :select => 'users.id')   @id.each do |i|            @pic = ActiveRecord::Base.connection.select_value(                                                     select picture from albums a                                                     inner join Users u on u.id = a.id                                                     where u.id = i )        end end

please give me some advices...

THanls you so much

Assuming your users have a "has_many :pictures" relationship:

  @pictures = User.all.map(&:pictures).flatten

Or if your Users have many Albums, and Albums have many Pictures:

  @pictures = User.all.map(&:albums).flatten.map(&:pictures).flatten

(can probably use .inject to make that smaller, but you can look that up in the api docs)

then you can iterate @pictures however you want in your views.

but.... hang on...

Aren't you just getting a list of all the Pictures? Why not use "Picture.all"?

Sorry, I mean get the list of user id …

cuz my query depends on user.id … so i want to have a list which is array to go through

the album…