On Jul 28, 3:17 am, Frederick Cheung <
frederick.che...@gmail.com>
wrote:
> If you have a plugin with a structure that looks like
>
> my_plugin/
> app/
> controllers/
> ...
>
> config/
> routes.rb
> lib/
> ...
>
> Then rails will add the routes from that routes.rb file. (Don't know
> if you have to have app/controllers, i've just always wanted to add a
> route to a controller that was also in the plugin).
>
> Since plugins can be packaged as gems, some variation on the above
> should work
>
> Fred
Interesting! I didn't that you could do that. Unfortunatey, I couldn't
get it to work.
$cat config/routes.rb
ActionController::Routing::Routes.draw do |map|
map.resource :dashboard, :only => :show
map.connect "dashboard/widgets/*path", :controller
=> :dashboards, :action => 'widget_data'
end
$
$ cat vendor/gems/acts_as_dashboard-0.0.0/config/routes.rb
puts "***** #{__FILE__}"
ActionController::Routing::Routes.draw do |map|
map.connect 'foo/*path', :controller => :dashboards
end
$
$ rake routes
(in /home/nick/src/acts_as_dashboard_container)
dashboard GET /dashboard(.:format)
{:action=>"show", :controller=>"dashboards"}
/dashboard/widgets/:path
{:action=>"widget_data", :controller=>"dashboards"}
$
Any idea why the gem's routes.rb isn't being processed?
Thanks!
Nick