Optional formats in routes

1 view
Skip to first unread message

Tom Stuart

unread,
Dec 9, 2008, 11:42:34 AM12/9/08
to resources_controller
Hi,

I can't explain this very well at the moment, but just to get the ball
rolling: resources_controller's named route helpers don't seem to play
nicely with the optional route formats in Edge Rails (cf
http://github.com/rails/rails/commit/fef6c32).

Something in the resources_path etc voodoo isn't working right. If
there's a current resource, e.g. if resource_path returns '/posts/
123', then resources_path now returns '/posts.123' instead of the
expected '/posts'. I guess it's inadvertently supplying the :format
parameter, presumably positionally.

The code in define_resource_named_route_helper_method_for_name_prefix
makes my eyes go a bit crossed -- any ideas for a simple way to fix
this up?

Cheers,
-Tom

Tom Stuart

unread,
Dec 9, 2008, 2:15:00 PM12/9/08
to resources_controller
On Dec 9, 4:42 pm, Tom Stuart <tom.stu...@gmail.com> wrote:
> resources_controller's named route helpers don't seem to play
> nicely with the optional route formats in Edge Rails (cfhttp://github.com/rails/rails/commit/fef6c32).

FWIW I've bodged this temporarily by adding :format to the list of
keys (previously just :controller and :action) that are removed from
the route's significant keys when computing required_args. I get the
feeling that this isn't really the right way to deal with it -- at
best it's overly specific and missing the opportunity to inspect the
route properly for something like required_segment_keys -- but it does
make it work for me again.

Ian White

unread,
Dec 10, 2008, 8:46:41 PM12/10/08
to resources_controller
Thanks Tom for the heads up, checking it out now.

Ian White

unread,
Dec 10, 2008, 11:18:08 PM12/10/08
to resources_controller
Applied, thanks Tom!

(goddam there's some old and ugly code in the named_routes stuff - I'm
thinking refactor time)

ps. there are still some issues with RC and current edge - some
controller specs are getting unrecgonized route errors, that's next.
Reply all
Reply to author
Forward
0 new messages