I have 2 tables users and roles joined by a users_roles table, writing
the search module to list users according to parameters,
I can easily search on the user.login using :
conditions = ["login LIKE ?",
"%#{@params[:qlogin]}%"] unless
@params[:qlogin].nil?
but as I need also to offer a selection on the role, so I am using in
the view :
an- input type="checkbox" name="qrole"
id="qrole"
and a - select("role", "role_id", Role.to_dropdown)
can I write :
conditions += [" AND "] unless ( @params[:qlogin].nil? &&
@params[:qrole].nil? )
and
conditions += ["users.role.id = ?",
"#{@params[:role][:role_id]}"]
unless @params[:qrole].nil?
seems quite weird ?
kad
--
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
-~----------~----~----~----~------~----~------~--~---