2010-03-18 57 views
1

在這一段代碼:哪裏`signup`,`login`,`register`方法來自

ActionController::Routing::Routes.draw do |map| 
    map.resources :line_items 
    map.resources :orders 
    map.resources :products 
    map.resources :categories 

    map.logout '/logout', :controller => 'sessions', :action => 'destroy' 
    map.login '/login', :controller => 'sessions', :action => 'new' 
    map.register '/register', :controller => 'user', :action => 'create' 
    map.signup '/signup', :controller => 'user', :action => 'new' 
    map.connect '/add-to-cart', :controller => 'line_items', :action => 'new' 
end 

map對象具有方法connectresources調用,它在ActionController documentation中描述。其他的定義/描述在哪裏?它們是由RESTful認證插件生成的。

我應該如何將/add-to-cart映射到其動作/控制器,以便自動生成add_to_cart_path方法?

回答

1

這是通過method_missing的魔法完成的。