安装基础后设计sign_out sops工作

时间:2014-12-21 18:49:18

标签: ruby-on-rails devise zurb-foundation

我正在制作一个简单的应用程序,所有关于设计的工作正常,直到我安装了Foundation 5.5.0。在此之后,sign_out按钮给我以下erorr:

No route matches [GET] "/users/sign_out"

我的sign_out按钮代码如下:

<%= link_to 'Sign out' , destroy_user_session_path, method: :delete %>

这是生成的HTML:

<a data-method="delete" href="/users/sign_out" rel="nofollow">Salir</a>

我的application.js:

//= require jquery
//= require jquery_ujs
//= require foundation
//= require turbolinks
//= require_tree .

$(function(){ $(document).foundation(); });

我的application.css

*= require_tree .
*= require_self
*= require foundation_and_overrides
*= require foundation

我的layout.html.erb头:

<head>
   <meta charset="utf-8" />
   <meta name="viewport" content="width=device-width, initial-scale=1.0" />

   <title><%= content_for?(:title) ? yield(:title) : "foundation-rails" %></title>

   <%= stylesheet_link_tag    "application" %>
   <%= javascript_include_tag "vendor/modernizr" %>
   <%= javascript_include_tag "application" 'data-turbolinks-track' => true %>
   <%= csrf_meta_tags %>
</head>

我按照本指南安装了Foundation:http://foundation.zurb.com/docs/applications.html

正如您所看到的,我的设置非常基本,所以我的问题是为什么在安装Foundation之后它会开始向服务器发送GET请求而不是DELETE请求?我该怎么做才能解决这个问题?

提前多多感谢

修改

的routes.rb

Rails.application.routes.draw do
   devise_for :users

耙路线

new_user_session     GET    /users/sign_in(.:format)       devise/sessions#new
user_session         POST   /users/sign_in(.:format)       devise/sessions#create
destroy_user_session DELETE /users/sign_out(.:format)      devise/sessions#destroy
user_password        POST   /users/password(.:format)      devise/passwords#create
new_user_password    GET    /users/password/new(.:format)  devise/passwords#new
edit_user_password   GET    /users/password/edit(.:format) devise/passwords#edit
                     PATCH  /users/password(.:format)      devise/passwords#update
                     PUT    /users/password(.:format)      devise/passwords#update

通过修改layout.html.erb来解决我自己的问题:

<head>
   <meta charset="utf-8" />
   <meta name="viewport" content="width=device-width, initial-scale=1.0" />

   <title><%= content_for?(:title) ? yield(:title) : "foundation-rails" %></title>

   <%= javascript_include_tag "application" %>
   <%= javascript_include_tag 'data-turbolinks-track' => true %> 
   <%# Doesn't work if I put the turbolinks and the application tags together as it was before%>
   <%= stylesheet_link_tag    "application" %>
   <%= javascript_include_tag "vendor/modernizr" %>
   <%= csrf_meta_tags %>
</head>

0 个答案:

没有答案