我刚刚在我的应用程序上安装了Devise,我之前已经像迈克尔哈特教程那样做了一些.
没有路由匹配[POST]“/ sessions / user”
当我点击登录/登录按钮时,无论是否有(正确的)密码,都会发生这种情况.
我的路线文件是:
SampleApp::Application.routes.draw do devise_for :users,path_names: { sign_in: "login",sign_out: "logout"} resources :users do resources :bookings,only: [:show] end resources :bookings resources :sessions # match '/signup',to: 'devise/registrations#new',via: :get # match '/signin',to: 'devise/sessions#new',via: [:post,:get] # match '/signout',to: 'devise/sessions#destroy',via: :delete match '/admin',to: 'admin#new',via: :get match "bookings/new",to: 'bookings#new',:get] devise_scope :user do root to: 'static_pages#home' end
[编辑]
我的表单是设计的默认形式:
<h2>Sign in</h2> <%= form_for(resource,:as => resource_name,:url => session_path(resource_name)) do |f| %> <div><%= f.label :email %><br /> <%= f.email_field :email,:autofocus => true %></div> <div><%= f.label :password %><br /> <%= f.password_field :password %></div> <% if devise_mapping.rememberable? -%> <div><%= f.check_Box :remember_me %> <%= f.label :remember_me %></div> <% end -%> <div><%= f.submit "Sign in" %></div> <% end %>
目前,在Michael Hartl教程中,我没有关于Session Controller和Helper的任何代码
我关于Sessions的佣金路线如下:
sessions GET /sessions(.:format) sessions#index POST /sessions(.:format) sessions#create new_session GET /sessions/new(.:format) sessions#new edit_session GET /sessions/:id/edit(.:format) sessions#edit session GET /sessions/:id(.:format) sessions#show PATCH /sessions/:id(.:format) sessions#update PUT /sessions/:id(.:format) sessions#update DELETE /sessions/:id(.:format) sessions#destroy
[解决了]
我更新了路线文件
devise_scope :user do root to: 'static_pages#home' match '/sessions/user',to: 'devise/sessions#create',via: :post end