Created
July 28, 2009 17:41
-
-
Save jacobo/157553 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Routes: | |
ActionController::Routing::Routes.draw do |map| | |
# restful routes | |
map.resources :users | |
# default routes | |
map.connect ':controller/:action/:id' | |
map.connect ':controller/:action/:id.:format' | |
end | |
#Controller: | |
class UsersController < ApplicationController | |
def index | |
render :text => "url for show: #{url_for(:action => 'show', :id => 1)}, url for login: #{url_for(:action => 'login')}" | |
end | |
def show | |
render :text => "Show action called with id #{params[:id]}" | |
end | |
def login | |
render :text => "Login action called" | |
end | |
end | |
#Notes: | |
# So then if I hit the index action, I see: | |
"url for show: http://localhost:3000/users/1, url for login: http://localhost:3000/users/login" | |
# But if I then go to that URL for login (http://localhost:3000/users/login), it hits the show action: | |
"Show action called with id login" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment