代码之家  ›  专栏  ›  技术社区  ›  plehoux

没有匹配的路由:action=>“destroy”,:controller=>“users”

  •  10
  • plehoux  · 技术社区  · 16 年前

    当我试图通过一个命名路由访问用户显示页面时,出现了一个错误(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'
    
    1 回复  |  直到 13 年前
        1
  •  25
  •   Gediminas Å ukys kicaj    13 年前