开发者

Rails route which disappears in application but is present in rake routes

I have a mystic problem....

In my routes.rb I have some routes defined and for exemple

resources :projects, :except => [:destroy] do
  get :edit_flyer, :on => :member
  get :guests, :on => :member
end

If I run a rake routes, I get

                     edit_flyer_project GET    /projects/:id/edit_flyer(.:format)                      {:controller=>"projects", :action=>"edit_flyer"}开发者_JAVA技巧
                         guests_project GET    /projects/:id/guests(.:format)                          {:controller=>"projects", :action=>"guests"}
                                        GET    /projects(.:format)                                     {:controller=>"projects", :action=>"index"}
                               projects POST   /projects(.:format)                                     {:controller=>"projects", :action=>"create"}
                            new_project GET    /projects/new(.:format)                                 {:controller=>"projects", :action=>"new"}
                                        GET    /projects/:id(.:format)                                 {:controller=>"projects", :action=>"show"}
                                project PUT    /projects/:id(.:format)                                 {:controller=>"projects", :action=>"update"}
                           edit_project GET    /projects/:id/edit(.:format)                            {:controller=>"projects", :action=>"edit"}

As you can see, the show action is defined. But in my rails applications, the route show is not defined.

I add this in my application controller just to monitored the routes.

before_filter :zba

def zba
  ActionController::Routing::Routes.named_routes.routes.each do |name, route|
    puts "%20s: %s" % [name, route]
  end
  exit
end

And it appears that the route action is not defined ....

Then, I tryed to clean my routes.rb, like removing all my back namespace, and magically it works.

It seems to be a bug, or I don't know what appened.

Have you any idea how to debug this ? I also tryed to remove plugin/gems. No change.

I run with Rails3.rc with ruby 1.8.7 !

Thanks for your help !


Try this

resources :projects, :except => [:destroy] do
  member do
    get :edit_flyer
    get :guests
  end
end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜