#34 Named Routes

When you add a custom route, make it a named route so you have url helper methods to easily link to that new route. See episode for details.
# routes.rb
map.resources :projects
map.task_archive 'tasks/:year/:month', :controller => 'tasks', :action => 'archive'
map.home '', :controller => 'projects', :action => 'index'


    <% for project in @projects %>

  • <%= link_to project.name, project_path(project) %>
    | <%= link_to "Edit", edit_project_path(project) %>
    | <%= link_to "Destroy", project_path(project), :method => :delete %>

  • <% end %>


<%= link_to "New Project", new_project_path %>

你可能感兴趣的:(Railscasts)