我想确保用户为我的网站启用了 cookie,所以我使用了本指南。
但是,当我运行我的服务器时,我发现了这个错误:
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)