当我试图通过一个命名路由访问用户显示页面时,出现了一个错误(http://localhost:3000/profile/)…否则,当我尝试使用标准URL(http://localhost:3000/users/current)访问它时,不会出现任何错误。如果我耙路线,我的路线似乎是正确的,因为它与标准的网址,我真的不知道为什么我没有路线匹配错误。当我甚至不想访问它时,为什么要尝试查找与“销毁”操作匹配的路由?
Starcast::Application.routes.draw do
match "login" => 'user_sessions#new', :as => :login
match "logout" => 'user_sessions#destroy', :as => :logout
resources :user_sessions
match "profile" => 'users#show'
resources :users
resources :casters
resources :casts
resources :orders
root :to => "home#index"
end
我得到的错误:
ActionView::Template::Error (No route matches {:action=>"edit", :controller=>"users"}):
1: <% title "Welcome #{@user.username}" %>
2:
3: <%= link_to "Edit your profil", edit_user_path %>
4:
5: <% has_role? :caster do %>
6: <% if @user.caster %>
app/views/users/show.html.erb:3:in `_app_views_users_show_html_erb___2116234531537545622_2170017780__3613739707062673465'