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
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2009-Mar-05 09:44 UTC
Re: Retrieving all values of the column from the table
On Mar 5, 9:26 am, vimal <cool.vimalsm...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I dont know whether i am doing it right or notWell, have you tried it ? (look up the send method) Fred --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---