Rails 3 Controller
Routes
defined in config/routes.rb
:
match ':controller(/:action(/:id(.:format)))' # default route, :id and :format may be accessed as parameters in the action match '/teams/home' => 'teams#index' # call index action of teams controller match '/teams/search/:query' => 'teams#search' # sends :query parameter to search action in teams controller match '/teams/search/:query' => 'teams#search', :as => 'search' # named route, defines search_url and search_path methods
search_url
gives http://example.com/teams/search
,
search_path
gives /teams/search
useful in something like
link_to "Search", search_path