I dont think this is the way to do this at all.
I have been told it is not wise to have very nested resources (2
maximun) so with a better design, you might come up with something
where you can do filtering in routes
map.resources :pupils, :has_many => {:houses, :cohorts, ...}, :has_one
=> {:mansion, ...}
this will give you routes like
pupils/2/cohorts/:cohort_id => will go to controller cohorts, action
show and params will contain :pupil_id => 2
pupils/2/cohorts => will go to controller cohorts, action index and
params will contain :pupil_id => 2
pupils/2/houses/:cohort_id => will go to controller houses, action
show and params will contain :pupil_id => 2
... etc
so you dont have to write ALL the possible routes, but you have to
route all the parameters you want to filter by. This is a solution to
what it seems your problem here, but i suggest you have a good think
in your design as to why you would need to filter pupils in the routes
and not in the index page of the pupils controller (for example) or
somewhere where it is more "appropiate" (easier).
On Mar 15, 11:20 pm, johnsonmlw
<johnson...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> I have this in routes.rb:
>
> map.connect ''pupils/*filters'', :controller =>
"pupils", :action =>
> ":filter"
>
> Given this url, for example:
>
> http://localhost:3000/pupils/cohort_id/1/house_id/3
>
> I would like to be able to grab an unlimited number of values to
> filter pupils in the controller (so I don''t have to write out all
the
> options in route.rb)
>
> So far I have... (but clearly this isn''t going to work)
>
> def filter
> @pupils = Pupil.find(:all, :conditions => params[:filters])
> end
>
> I found this with google but it complains about an odd number of
> arguments:
>
> @pupils = Pupil.find(:all, :conditions => Hash[params[:filters]])
>
> Please help me with the controller find line, or tell me this
isn''t
> the way to be doing this at all.
>
> Thanks.
>
> --
> Matt
--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---