Rails 2.3.2 and config.action_controller.session

Further on migrating my ancient 1.8.6 Rails 2.3.2 app from Windows to
Linux
Mint, whatever I do, I keep getting the same error pertaining to “* A
key
is required to write a cookie containing the session data. Use
config.action_controller.session = { :key => “_myapp_session”, :secret
=>
“some secret phrase” } in config/environment.rb.”* This is true if I run
run ruby script/server, or rake rails:update. However, in my
config/environent.rb, I already have this statement the error is telling
me
I needed (in fact, it was commented out, but uncommenting it changes
nothing for me, I keep getting the same error whenever I go to run
something here). Anyone have an idea where else I can look here? Thaks,
RVic

  • ruby script/server
    /home/user/.rvm/gems/ruby-1.8.6-p420/gems/actionpack-2.3.2/lib/action_controller/session/cookie_store.rb:163:in
    ensure_session_key': A key is required to write a cookie containing the session data. Use config.action_controller.session = { :key => "_myapp_session", :secret => "some secret phrase" } in config/environment.rb (ArgumentError) from /home/user/.rvm/gems/ruby-1.8.6-p420/gems/actionpack-2.3.2/lib/action_controller/session/cookie_store.rb:74:ininitialize’
    from
    /home/user/.rvm/gems/ruby-1.8.6-p420/gems/actionpack-2.3.2/lib/action_controller/middleware_stack.rb:72:in
    new' from /home/user/.rvm/gems/ruby-1.8.6-p420/gems/actionpack-2.3.2/lib/action_controller/middleware_stack.rb:72:inbuild’
    from
    /home/user/.rvm/gems/ruby-1.8.6-p420/gems/actionpack-2.3.2/lib/action_controller/middleware_stack.rb:116:in
    build' from /home/user/.rvm/gems/ruby-1.8.6-p420/gems/activesupport-2.3.2/lib/active_support/inflector.rb:361:ininject’
    from
    /home/user/.rvm/gems/ruby-1.8.6-p420/gems/actionpack-2.3.2/lib/action_controller/middleware_stack.rb:116:in
    each' from /home/user/.rvm/gems/ruby-1.8.6-p420/gems/actionpack-2.3.2/lib/action_controller/middleware_stack.rb:116:ininject’
    from
    /home/user/.rvm/gems/ruby-1.8.6-p420/gems/actionpack-2.3.2/lib/action_controller/middleware_stack.rb:116:in
    build' ... 8 levels... from ./script/../config/boot.rb:11:inboot!’
    from ./script/…/config/boot.rb:110
    from script/server:2:in `require’
    from script/server:2

On Mon, Oct 28, 2013 at 12:45 PM, RVic [email protected] wrote:

Further on migrating my ancient 1.8.6 Rails 2.3.2 app from Windows to Linux
Mint

Are you sure your time wouldn’t be better spent just moving straight
to current versions of Ruby and Rails? :slight_smile:

It might actually be easier than what you’re doing now, and at the end
you’d have something besides a running but obsolete application with
known security vulnerabilities…

Just a suggestion!


Hassan S. ------------------------ [email protected]

twitter: @hassan

On Mon, Oct 28, 2013 at 4:09 PM, Hassan S. <
[email protected]> wrote:

Hassan,

Oh I certainly will be migrating it – I;ve just got the order though to
get this thing up and running in a linux vm asap. Hopefully, Im not far
from that. But there;s a lot that Iwill have to migrate to the new
mechanisms (routes are different, invoking the server is different,
etc.)
Thank you!

On 28 October 2013 19:45, RVic [email protected] wrote:

Further on migrating my ancient 1.8.6 Rails 2.3.2 app from Windows to Linux
Mint, whatever I do, I keep getting the same error pertaining to " A key is
required to write a cookie containing the session data. Use
config.action_controller.session = { :key => “_myapp_session”, :secret =>
“some secret phrase” } in config/environment.rb." This is true if I run run
ruby script/server, or rake rails:update. However, in my
config/environent.rb,

Can you paste your environment.rb here please?

Colin

On Mon, Oct 28, 2013 at 5:12 PM, Colin L. [email protected]
wrote:

Can you paste your environment.rb here please?

Colin

Thanks Colin!

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

Uncomment below to force Rails into production mode when

you don’t control web/app server and can’t set it the proper way

ENV[‘RAILS_ENV’] ||= ‘production’

Specifies gem version of Rails to use when vendor/rails is not present

RAILS_GEM_VERSION = ‘2.1.2’ unless defined? RAILS_GEM_VERSION

Bootstrap the Rails environment, frameworks, and default configuration

require File.join(File.dirname(FILE), ‘boot’)
require ‘paginator’

Rails::Initializer.run do |config|

Settings in config/environments/* take precedence those specified

here

Skip frameworks you’re not going to use

#config.frameworks -= [ :action_web_service, :action_mailer ]

Add additional load paths for your own custom dirs

config.load_paths += %W( #{RAILS_ROOT}/extras )

config.load_paths += %W( #{RAILS_ROOT}/app/reports )

Required for Ruports:

config.after_initialize do
require “ruport”
end

**SEE CONFIG_LOAD_PATHS ABOVE and require “app/reports/templates”

BELOW**
###########################

Force all environments to use the same logger level

(by default production uses :info, the others :debug)

config.log_level = :debug

Use the database for sessions instead of the file system

which shouldn’t be used to store highly confidential information

(create the session table with ‘rake db:sessions:create’)

config.action_controller.session_store = :active_record_store

Use SQL instead of Active Record’s schema dumper when creating the

test
database.

This is necessary if your schema can’t be completely dumped by the

schema dumper,

like if you have constraints or database-specific column types

config.active_record.schema_format = :sql

Activate observers that should always be running

config.active_record.observers = :cacher, :garbage_collector

Make Time.zone default to the specified zone, and make Active Record

store time values
# in the database in UTC, and return them converted to the
specified
local zone.
# Run “rake -D time” for a list of tasks for finding time zone
names.
Comment line to use default local time.
config.active_record.default_timezone = :utc

See Rails::Configuration for more options

Your secret key for verifying cookie session data integrity.

If you change this key, all old sessions 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.

config.action_controller.session = {
:key => “_gg_session”,
:secret =>
“caf079519f0a811fa0ba9a0a3202c93f62d9f86ca4f1981harverdouccioe55e3869ee4aa8cbb48aecb518f1059103b7eb49b513f4d6ddc40d92e9488785eb90689229ad”
}

config.gem “authlogic”
config.gem “actionmailer”
config.gem “calendar_date_select”
config.gem “paginator”
config.gem “builder”
end

require “app/reports/templates”

Add new inflection rules using the following format

(all these examples are active by default):

Inflector.inflections do |inflect|

inflect.plural /^(ox)$/i, ‘\1en’

inflect.singular /^(ox)en/i, ‘\1’

inflect.irregular ‘person’, ‘people’

inflect.uncountable %w( fish sheep )

end

Include your application configuration below

On 28 October 2013 21:19, Ralph V. [email protected] wrote:

Thanks Colin!

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

Uncomment below to force Rails into production mode when

you don’t control web/app server and can’t set it the proper way

ENV[‘RAILS_ENV’] ||= ‘production’

Specifies gem version of Rails to use when vendor/rails is not present

RAILS_GEM_VERSION = ‘2.1.2’ unless defined? RAILS_GEM_VERSION

The above line should not be commented out, but should of course
reference ‘2.3.2’. I don’t know whether that might have anything to
do with it or not.

Bootstrap the Rails environment, frameworks, and default configuration

require File.join(File.dirname(FILE), ‘boot’)
require ‘paginator’

The line above should not be there, again I don’t know whether it is
relevant to the problem.

config.load_paths += %W( #{RAILS_ROOT}/app/reports )

(by default production uses :info, the others :debug)

config.log_level = :debug

Use the database for sessions instead of the file system

which shouldn’t be used to store highly confidential information

(create the session table with ‘rake db:sessions:create’)

Have you done the above? Either do that and/or comment out the line
below, at least until it is working.

config.active_record.observers = :cacher, :garbage_collector

See Rails::Configuration for more options

Your secret key for verifying cookie session data integrity.

If you change this key, all old sessions 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.

config.action_controller.session = {
:key => “_gg_session”,

That should be :session_key I think, at least that is what I have, in
which case the error message is wrong.

Include your application configuration below

Colin

On Mon, Oct 28, 2013 at 5:32 PM, Colin L. [email protected]
wrote:

Colin

Specifies gem version of Rails to use when vendor/rails is not present

#config.frameworks -= [ :action_web_service, :action_mailer ]
BELOW**
Have you done the above? Either do that and/or comment out the line

config.active_record.schema_format = :sql

Comment line to use default local time.
:key => “_gg_session”,
config.gem “actionmailer”

inflect.plural /^(ox)$/i, ‘\1en’

Colin

Colin, I made the changes you said to make here (I did, well before, do
rake db:sessions:create and have the table resident in the db). I;ve lso
tried using :session_key in instead of :key…noe of which seems to be
affecting it:

ruby script/server
/home/user/.rvm/gems/ruby-1.8.6-p420/gems/actionpack-2.3.2/lib/action_controller/session/cookie_store.rb:163:in
ensure_session_key': A key is required to write a cookie containing the session data. Use config.action_controller.session = { :key => "_myapp_session", :secret => "some secret phrase" } in config/environment.rb (ArgumentError) from /home/user/.rvm/gems/ruby-1.8.6-p420/gems/actionpack-2.3.2/lib/action_controller/session/cookie_store.rb:74:in initialize’

On 28 October 2013 21:46, Ralph V. [email protected] wrote:

session data. Use config.action_controller.session = { :key =>
“_myapp_session”, :secret => “some secret phrase” } in config/environment.rb
(ArgumentError)
from

/home/user/.rvm/gems/ruby-1.8.6-p420/gems/actionpack-2.3.2/lib/action_controller/session/cookie_store.rb:74:in

`initialize’

It is very odd, firstly it should not be using the cookie store, and
if it were then you have provided the session key. I have tried it
and it works for me with either :key or :session_key, and if I enable
the active_record_store then it does not ask in the first place.

Can you post development.rb please.

Colin

On 28 October 2013 21:51, Ralph V. [email protected] wrote:

`ensure_session_key’
That is not all that surprising, it has to load the environment in
order to run rake.

Colin

I think the issue may be something else Colin. For example, this error
seems to crop up no matte what the command is:

user@Mint15-32 ~/ggrip/ggripv2 $ rake rails:update
rake aborted!
A key is required to write a cookie containing the session data. Use
config.action_controller.session = { :key => “_myapp_session”, :secret
=>
“some secret phrase” } in config/environment.rb
/home/user/.rvm/gems/ruby-1.8.6-p420/gems/actionpack-2.3.2/lib/action_controller/session/cookie_store.rb:163:in
`ensure_session_key’

On 28 October 2013 22:04, Ralph V. [email protected] wrote:

the active_record_store then it does not ask in the first place.

#config.breakpoint_server = true

set delivery method to :smtp, :sendmail or :test

:domain => ‘www.example.com’,
:authentication => :login,
:user_name => ‘cfgsr’,
:password => ‘p6687sq5’
}

That all looks ok. Sorry I am out of ideas. I can only suggest that
you try making a new app (I can’t remember how to do that in rails 2,
you will have to look it up if you don’t know), and see if that works.
Then if that works add stuff in from your app till it breaks.

Colin

Wait,

Stupid me.

The database login parameters have changed – when I change that, it
gets
past that error (give me a new one, of coursem but that must be the
problem). I fixed it in database.yml.

On Mon, Oct 28, 2013 at 5:58 PM, Colin L. [email protected]
wrote:

Thanks Colin, Development.rb:

Settings specified here will take precedence over those in

config/environment.rb
#require “ruby-debug”

In the development environment your application’s code is reloaded on

every request. This slows down response time but is perfect for

development

since you don’t have to restart the webserver when you make code

changes.
config.cache_classes = false

Log error messages when you accidentally call methods on nil.

config.whiny_nils = true

Enable the breakpoint server that script/breakpointer connects to

#config.breakpoint_server = true

Show full error reports and disable caching

config.action_controller.consider_all_requests_local = true
config.action_controller.perform_caching = false
#config.action_view.cache_template_extensions = false
config.action_view.debug_rjs = true

config/environments/development.rb

config.action_mailer.raise_delivery_errors = true

set delivery method to :smtp, :sendmail or :test

config.action_mailer.delivery_method = :smtp

#set default type to html. Options are “text/plain”, “text/html”, and
“text/enriched”. The default value is “text/plain”.
config.action_mailer.default_content_type = “text/html”

these options are only needed if you choose smtp delivery

config.action_mailer.smtp_settings = {
:address => ‘outgoing.verizon.net’,
:port => 25,
:domain => ‘www.example.com’,
:authentication => :login,
:user_name => ‘cfgsr’,
:password => ‘p6687sq5’
}

And…once I get that one fixed…I’m right back to the original error!

Thanks Colin.

How would you enable active_record_store? Perhaps I should try that
first?

I think there’s more wrong here than what the error message suggests.
For
example:

user@Mint15-32 ~/ggrip/ggripv2 $ gem install rails -v 2.3.2
Successfully installed rails-2.3.2
1 gem installed
Installing ri documentation for rails-2.3.2…
Installing RDoc documentation for rails-2.3.2…

user@Mint15-32 ~/ggrip/ggripv2 $ rails -v
The program ‘rails’ can be found in the following packages:

  • rails
  • ruby-railties-3.2
    Try: sudo apt-get install

When I did rails - v, shouldn;t it have just returned 2.3.2 ?

On Oct 28, 2013, at 6:29 PM, Ralph V. wrote:

  • rails
  • ruby-railties-3.2
    Try: sudo apt-get install

When I did rails - v, shouldn;t it have just returned 2.3.2 ?

Yes. I’m late to the party here, but are you using rvm on this server?
What does your PATH look like? If you aren’t using rvm, then have you
tried using sudo, as in

sudo gem install rails -v 2.3.2

Without rvm, you may be installing these binaries somewhere that your
PATH can’t find them.

Walter

On Mon, Oct 28, 2013 at 6:33 PM, Walter Lee D.
[email protected]wrote:

Walter

Walter,

I AM using rvm. My path:

user@Mint15-32 ~/ggrip/ggripv2 $ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/user/.rvm/bin

On Mon, Oct 28, 2013 at 7:30 PM, Hassan S. <
[email protected]> wrote:

ruby and gemset you’d selected. Which it obviously doesn’t.

Easy test: what does rvm current report? If it’s not what you want,
that’s the first thing to fix.

Hassan,

user@Mint15-32 ~/ggrip/ggripv2 $ rvm current
ruby-1.8.6-p420

which is correct. The /home/user/.rvm/bin in the PATH is correct, yes?
What
else are you saying should be in the PATH? THanks.

On Mon, Oct 28, 2013 at 3:42 PM, R Vince [email protected] wrote:

I AM using rvm. My path:

user@Mint15-32 ~/ggrip/ggripv2 $ echo $PATH

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/user/.rvm/bin

Uh, well. It looks like rvm is installed, but you’re not actually using
it.
If you were, your path would start with the rvm bin directories for the
ruby and gemset you’d selected. Which it obviously doesn’t.

Easy test: what does rvm current report? If it’s not what you want,
that’s the first thing to fix.


Hassan S. ------------------------ [email protected]

twitter: @hassan