Hi,
I am using this code from railscast for searching in my activerecords:
http://railscasts.com/episodes/37-simple-search-form
There is this method in the 'Product'-Model, which is searching for
the product name:
class Project < ActiveRecord::Base
has_many :tasks
validates_presence_of :name
def self.search(search)
if search
find(:all, :conditions => ['name LIKE ?', "%#{search}%"]) #Rails
2
where('name LIKE ?', "%#{search}%") #Rails 3
else
find(:all)
end
end
end
My question is now, how can I search for products that have a given
task name. Task is a nested attribute for Product. I only use one of
the search line above. The second one is only possible with Rails 3.
I don't find anything about nested queries for activerecords with
'find' or 'where'.
I hope someone can help!
Sebastian
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.