开发者

Where does `signup`, `login`, `register` methods come from

In this piece of code:

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 object has methods connect and resources called, which are described in Ac开发者_StackOverflowtionController documentation. Where are the other ones defined/described? They were generated by RESTful authentication plugin.

How should I map /add-to-cart to its action/controller, to have automatically add_to_cart_path method generated?


These are called named routes.


It's done via the magic of method_missing.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜