Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby-on-Rails变量会话nill-on-change控制器_Ruby On Rails_Ruby_Ruby On Rails 3_Session_Ruby On Rails 3.2 - Fatal编程技术网

Ruby-on-Rails变量会话nill-on-change控制器

Ruby-on-Rails变量会话nill-on-change控制器,ruby-on-rails,ruby,ruby-on-rails-3,session,ruby-on-rails-3.2,Ruby On Rails,Ruby,Ruby On Rails 3,Session,Ruby On Rails 3.2,我是RubyonRails的新手 当我将数据放入变量会话[:user_id]并重定向到其他页面时,下一个控制器看不到该会话。它返回session={} user = User.find_by_email(params[:email]) if user && user.authenticate(params[:password]) session[:user_id] = user.id redirect_to pages_url, notic

我是RubyonRails的新手

当我将数据放入变量会话[:user_id]并重定向到其他页面时,下一个控制器看不到该会话。它返回session={}

user = User.find_by_email(params[:email])
    if user && user.authenticate(params[:password])
        session[:user_id] = user.id
        redirect_to pages_url, notice: "Hello"
    end
我看到应用程序告诉我一个警告:

WARNING: Can't verify CSRF token authenticity
查看internet,我发现若csrf令牌真实性不正常,会话变量将被删除

我在shell rake secret上运行,并在config/initializers/secret_token.rb中复制和粘贴:

# Be sure to restart your server when you modify this file.

# Your secret key for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
myApp::Application.config.secret_token = '4a5c2aabe7610666ac793d425ece06f24c87747a38d14991b4f352780e55b17e9bcee977c1579eec99e1d30f506671903ab87601346f0e96102a187df2aff1e6'
我在config/initializers/session_store.rb中也有这个

# Be sure to restart your server when you modify this file.

myApp::Application.config.session_store :cookie_store, :key => '_myApp_session', :domain => :all

# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with "rails generate session_migration")
# myApp::Application.config.session_store :active_record_store

也许我配置了错误的秘密令牌?也许我可以用其他方式访问会话变量?

很抱歉这样说,但这确实是一个选项:更改后是否重新启动了服务器?是的,我多次重新启动了服务器。