@avenger_powers = Power.where(whatever).includes(User.all.superhero)
On Feb 28, 12:36 am, simpleton
<brand.magn...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> I have a User model with a scope :superhero and I want to do an AR
> query along the lines of:
>
> @avengers_powers = Power.where(etc.).includes(User.where( #{this is
> where I want to limit by superhero scope} ))
>
> My users schema is:
>
> create_table "users", :force => true do |t|
> t.string "uid"
> t.string "name"
> t.datetime "created_at"
> t.datetime "updated_at"
> t.string "token"
> t.text "ability"
> t.string "location"
> end
>
> My user model has:
>
> scope :superhero, where("ability like ''%laser
vision%'' OR ability like
> ''%invisibility%''")
> scope :hobo, where("location like ''%cardboard
box%''")
>
> Seeing as :superhero and :hobo aren''t attributes on the user
model,
> how would I query it?
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.