I''ve got an array that I want to use to access a database with. I want
to execute a command like:
@people = Person.find([3, 5, 7])
but use an array variable inside the find. When I try this:
ids = Array.new()
ids << 3
ids << 5
ids << 7
@people = Person.find(#{ids})
The output turns out to be:
@people = Person.find(357)
Is there a way to retain the array without it being concatenated into a
string?
-Anthony
--
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
-~----------~----~----~----~------~----~------~--~---
@some = [1,2] @people = Person.find @some -- 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 -~----------~----~----~----~------~----~------~--~---
yours should work fine if you didn''t convert it into a string!> ids = Array.new() > ids << 3 > ids << 5 > ids << 7@people = Person.find(ids) On Dec 12, 1:41 pm, Anthony Walsh <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I''ve got an array that I want to use to access a database with. I want > to execute a command like: > > @people = Person.find([3, 5, 7]) > > but use an array variable inside the find. When I try this: > > ids = Array.new() > ids << 3 > ids << 5 > ids << 7 > > @people = Person.find(#{ids}) > > The output turns out to be: > > @people = Person.find(357) > > Is there a way to retain the array without it being concatenated into a > string? > > -Anthony > > -- > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---