Eri*_*mer 2 ruby-on-rails devise
我目前正在使用Devise获取此错误,我已尝试过其他问题的多个内容,以便通过ZERO运气来解决它.
我首先建议确保将该方法添加为删除:
<%= link_to "Logout", destroy_user_session_path, :method => :delete, :class => 'navbar-link' %>
Run Code Online (Sandbox Code Playgroud)
没运气.
然后我被告知我需要在我的布局标题中包含这个:
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
Run Code Online (Sandbox Code Playgroud)
或这个:
<%= javascript_include_tag :defaults %>
Run Code Online (Sandbox Code Playgroud)
还是......没有运气.
最后,我被建议更改我的/config/initializers/devise.rb文件以更改config.sign_out_via = :delete为config.sign_out_via = :get
没有运气.
我不知道还有什么可以尝试的,
这是我的HTML中的当前代码,如果您需要查看我的路线以更好地帮助您,请告诉我.
<!DOCTYPE html>
<html>
<header>
<h2><span>Anume*</span></h2>
<img id='header' src="http://wallpapercave.com/wp/hkWe2SK.jpg" alt="" />
</header>
<head>
<title>Anume</title>
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>
<body>
<p class="navbar-text pull-right">
<% if user_signed_in? %>
Logged in as
<strong><%= current_user.email %></strong>.
<%= link_to 'Edit profile', edit_user_registration_path, :class => 'navbar-link' %>
|
<%= link_to "Logout", destroy_user_session_path, :method => :delete, :class => 'navbar-link' %>
<% else %>
<%= link_to "Sign up", new_user_registration_path, :class => 'navbar-link' %>
|
<%= link_to "Login", new_user_session_path, :class => 'navbar-link' %>
<% end %>
</p>
</body>
Run Code Online (Sandbox Code Playgroud)
这是我的注销功能的rails路由:
destroy_user_session DELETE /users/sign_out(.:format) devise/session#destroy
Run Code Online (Sandbox Code Playgroud)
我喜欢做的一件事
/config/initializers/devise.rb是从更改config.sign_out_via = :delete到config.sign_out_via = [:delete, :get]所以你有两个方案覆盖incase删除方法没有命中.
打开你的控制台,确保jquery和jquery_ujs正确加载
让我与你分享我的设置
在我的资产application.js我有
#app/assets/javascripts/application.js
//= require jquery
//= require jquery_ujs
//= require turbolinks
Run Code Online (Sandbox Code Playgroud)
现在我的布局
#app/views/layouts/application.html.haml
!!!
%html{:lang => "en"}
%head
%meta{:charset => "utf-8"}/
%meta{:content => "IE=edge", "http-equiv" => "X-UA-Compatible"}/
%meta{:content => "width=device-width, initial-scale=1", :name => "viewport"}/
%title
Best Site Ever
= csrf_meta_tags
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload'
= javascript_include_tag 'application', 'data-turbolinks-track': 'reload'
%body
- if current_user
= link_to destroy_user_session_path, :method => :delete do
Logout
Run Code Online (Sandbox Code Playgroud)
我希望这能够提供帮助
| 归档时间: |
|
| 查看次数: |
2376 次 |
| 最近记录: |