Hi, everybody!
I am trying to figure out how to add a related model to an anonymous
scope to complete a search. Right now, I have this:
if request.post?
scope = Record.scoped({})
scope = scope.conditions "color = ?", params[:color] unless
params[:color] == ''--Select Color--''
scope = scope.conditions "size = ?", params[:size] unless
params[:size] == ''--Select Size--''
scope = scope.conditions "shape = ?", params[:shape] unless
params[:shape] == ''--Select Sample Rate--''
scope = scope.conditions "quantity = ?", params[:quantity]
unless params[:quantity] == ''--Select Quantity--''
scope = scope.conditions "file_short = ?", params[:length]
unless params[:length] == ''--Select Length--''
scope = scope.conditions "pair.run.widget = ?", params[:widget]
unless params[:widget] == ''--Select Name--''
@records = scope
end
Records belong to Pairs, and Pairs belong to Runs. Everything will
work fine unless a widget is selected, and I need to have it located,
at which point it returns a "No such column" from SQL. Is there a
work around to allow you to get to a related model?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---