Is there a way to accomplish this using find_by_* (or even find(:all)
using some sort of conditions) or must I resort to SQL (of which I
happily know very little).
find_by_xxx is mapped to a find :first, its counterpart is
find_all_by...
Were you to write it out in full you'd write
Person.find :all, :conditions => ["name in (?)", names]
or Person.find :all, :conditions => {:name => names}
I did try before the method
Person.find :all, :conditions => ["name in (?)", names]
or Person.find :all, :conditions => {:name => names}
but its gave me a error uninitialized constant Person.
It is must implement a method for Person in order to use it.
Thank
I did try before the method
Person.find :all, :conditions => ["name in (?)", names]
or Person.find :all, :conditions => {:name => names}
but its gave me a error uninitialized constant Person.
The error is telling you that Rails can't find a model named Person.rb. Do
you have one? And a table named persons?
Ok thanks I have solved the error uninitialized constant Person but now
i have another error showing me that i have a nil object when you didn't
expect it! (NoMethodError).
The error occurred while evaluating
nil.find :all, :conditions => {:name => names}
Ok thanks I have solved the error uninitialized constant
Person but now i have another error showing me that i
have a nil object when you didn't expect it! (NoMethodError).
The error occurred while evaluating
nil.find :all, :conditions => {:name => names}
You'll need to show us some code to help further. How exactly did you solve
the unintialized constant error?