How can I make resources_controller ignore a path_prefix

1 view
Skip to first unread message

Martyn Loughran

unread,
Nov 11, 2008, 7:21:35 AM11/11/08
to resources_controller
In this example "anything" is just a string which is irrelevant from a
resources perspective:

map.with_options(:path_prefix => "anything") do |thing|
thing.resources :posts
end

This doesn't work:

* Resources controller tries to load the route segment as a class

Would be grateful for some pointers for the best way around this.

Thanks,

Martyn

This is the relevant part of the stacktrace:

uninitialized constant Anything

vendor/rails/activesupport/lib/active_support/dependencies.rb:431:in
`load_missing_constant'
vendor/rails/activesupport/lib/active_support/dependencies.rb:77:in
`const_missing'
vendor/rails/activesupport/lib/active_support/dependencies.rb:89:in
`const_missing'
vendor/rails/activesupport/lib/active_support/inflector.rb:353:in
`constantize'
vendor/rails/activesupport/lib/active_support/inflector.rb:352:in
`each'
vendor/rails/activesupport/lib/active_support/inflector.rb:352:in
`constantize'
vendor/rails/activesupport/lib/active_support/core_ext/string/
inflections.rb:162:in `constantize'
vendor/plugins/resources_controller/lib/ardes/resources_controller/
specification.rb:88:in `initialize'
vendor/plugins/resources_controller/lib/ardes/resources_controller/
specification.rb:21:in `new'
vendor/plugins/resources_controller/lib/ardes/resources_controller/
specification.rb:21:in `new'
vendor/plugins/resources_controller/lib/ardes/resources_controller/
specification.rb:21:in `new'
vendor/plugins/resources_controller/lib/ardes/resources_controller.rb:
764:in `load_wildcard'
vendor/plugins/resources_controller/lib/ardes/resources_controller.rb:
787:in `load_wildcards_from'
vendor/plugins/resources_controller/lib/ardes/resources_controller.rb:
787:in `times'
vendor/plugins/resources_controller/lib/ardes/resources_controller.rb:
787:in `load_wildcards_from'
vendor/plugins/resources_controller/lib/ardes/resources_controller.rb:
746:in `load_enclosing_resources'

Ian White

unread,
Nov 12, 2008, 9:40:43 PM11/12/08
to resources_...@googlegroups.com
Hi Martyn,

RC works with namespaces (in routes), so it should be pretty easy to
adapt to fix the problem you;re having.

Would you be interested in contributing some specs and/or a patch?

Cheers,
Ian

Martyn Loughran

unread,
Nov 18, 2008, 12:02:39 PM11/18/08
to resources_controller
Thanks Ian. The trouble is, I've hardly used resources controller
myself, so I'm not really familiar enough with the API to have a good
feeling for the correct API would be. If there's a way to read to
routes definition and realize that the path prefix should be ignored
then that would seem to be the cleanest option; I suspect it's not
possible.
Reply all
Reply to author
Forward
0 new messages