Retrieving all values of the column from the table

Hi,

I have a function in my model like

class Pattern
def self.get_all(field)
@patterns = Pattern.find(:all)
@patterns.collect do |pp|
pp.field
end
end
end

so that whatever field i give to the function,
it returns all the column values in an Array

I dont know whether i am doing it right or not
Any suggestions

Thanx,
Vimal Das

On Mar 5, 9:26 am, vimal [email protected] wrote:

I dont know whether i am doing it right or not

Well, have you tried it ? (look up the send method)

Fred

I tried it Fred,but it didn’t work

Instead this did the job for me

class Pattern
def self.get_all(field)
@patterns = Pattern.find(:all)
@patterns.collect do |pp|
pp[field]
end
end
end

Regards,
Vimal Das