Created
November 17, 2010 22:43
-
-
Save rubiii/704272 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
MyApp::Application.routes.draw do | |
resource :contacts | |
end | |
# which creates the following routes: | |
# | |
# contacts POST /contacts(.:format) {:controller=>"contacts", :action=>"create"} | |
# new_contacts GET /contacts/new(.:format) {:controller=>"contacts", :action=>"new"} | |
# edit_contacts GET /contacts/edit(.:format) {:controller=>"contacts", :action=>"edit"} | |
# GET /contacts(.:format) {:controller=>"contacts", :action=>"show"} | |
# PUT /contacts(.:format) {:controller=>"contacts", :action=>"update"} | |
# DELETE /contacts(.:format) {:controller=>"contacts", :action=>"destroy"} |
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
# this is a "stupid" helper i created to map the rails3 route-syntax to :controller and :action values | |
module ApplicationHelper | |
def route_link(name, route, html_options = {}) | |
route = route.split("#") | |
link_to(name, { :controller => route[0], :action => route[1] }, html_options) | |
end | |
end |
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
-# this shows how i would like to use "route-links": | |
= route_link "New Contact", "contacts#new" # expected output: '<a href="/contacts/new">New Contact</a>' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment