【问题标题】:Rails Cookie Detection Script FailsRails Cookie 检测脚本失败
【发布时间】:2013-03-02 01:29:49
【问题描述】:

我想确保用户为我的网站启用了 cookie,所以我使用了this guide

但是,当我运行我的服务器时,我发现了这个错误:

syntax error, unexpected $end, expecting keyword_end
map.cookies_test “cookie_test”, :controller...

这是我的 application_controller.rb :

class ApplicationController < ActionController::Base
    protect_from_forgery
    include CookieDetection
    include SessionsHelper
end

还有我的 routes.rb :

Basketball::Application.routes.draw do

  map.cookies_test “cookie_test”, :controller => “application”, :action => “cookie_test”

  resources :games 

  resources :teams

  get "teams/new"
  get "games/new"

  resources :users
  resources :sessions, only: [:new, :create, :destroy]

  root to: 'static_pages#home'

  match '/signup',  to: 'users#new'
  match '/signin',  to: 'sessions#new'
  match '/signout', to: 'sessions#destroy', via: :delete  

  match '/help',    to: 'static_pages#help'
  match '/about',   to: 'static_pages#about'
  match '/contact', to: 'static_pages#contact'

end

更新

我已将引号从“智能”引号更改为普通引号(根据 Edward),但现在出现错误:

undefined local variable or method `map' for#
<ActionDispatch::Routing::Mapper:0x007ff9ca996800> (NameError)

更新

我已将 Map 更改为 Match(根据 Edward),现在出现错误:

`match': wrong number of arguments (0 for 1) (ArgumentError)

【问题讨论】:

    标签: ruby-on-rails ruby cookies session-cookies


    【解决方案1】:

    在你的路由文件中,看起来你有“智能”引号“”,而不是普通的“”

    我猜你是错误地剪切和粘贴了它们。

    编辑


    更改地图以匹配 - 地图是 rails 2

    【讨论】:

      猜你喜欢
      • 2011-12-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-31
      • 2015-05-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多