Daniel ----- wrote:
You can make yourself some methods in application_controller.rb to have
the
methods available everywhere, or in a particular controller/helper if
that’s
what you need.
To get the foo in the session (or new if there isn’t a foo in the
session)
def foo
session[:foo] ? session[:foo] : Foo.new
end
To set the session foo
def foo=(a_foo)
session[:foo] = a_foo
end
then call
foo.bar
Ok I implemented that and it works for the first action, and then this
hits:
Application error
Change this error message for exceptions thrown outside of an action
(like in Dispatcher setups or broken Ruby code) in public/500.html
This was in the log file:
Session contains objects whose class definition isn’t available.
Remember to require the classes for all objects kept in the session.
(Original exception: uninitialized constant Generic [NameError])
./script/…/config/…/vendor/rails/actionpack/lib/action_controller/cgi_process.rb:147:in
`stale_session_check!’
./script/…/config/…/vendor/rails/actionpack/lib/action_controller/cgi_process.rb:107:in
`session’
./script/…/config/…/vendor/rails/actionpack/lib/action_controller/base.rb:887:in
`assign_shortcuts_without_flash’
./script/…/config/…/vendor/rails/actionpack/lib/action_controller/flash.rb:141:in
`assign_shortcuts’
./script/…/config/…/vendor/rails/actionpack/lib/action_controller/base.rb:375:in
`process_without_filters’
./script/…/config/…/vendor/rails/actionpack/lib/action_controller/filters.rb:377:in
`process_without_session_management_support’
./script/…/config/…/vendor/rails/actionpack/lib/action_controller/session_management.rb:117:in
`process’
./script/…/config/…/vendor/rails/railties/lib/dispatcher.rb:38:in
`dispatch’
./script/…/config/…/vendor/rails/railties/lib/webrick_server.rb:115:in
`handle_dispatch’
./script/…/config/…/vendor/rails/railties/lib/webrick_server.rb:81:in
`service’
c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service’
c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run’
c:/ruby/lib/ruby/1.8/webrick/server.rb:155:in `start_thread’
c:/ruby/lib/ruby/1.8/webrick/server.rb:144:in `start’
c:/ruby/lib/ruby/1.8/webrick/server.rb:144:in `start_thread’
c:/ruby/lib/ruby/1.8/webrick/server.rb:94:in `start’
c:/ruby/lib/ruby/1.8/webrick/server.rb:89:in `each’
c:/ruby/lib/ruby/1.8/webrick/server.rb:89:in `start’
c:/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start’
c:/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start’
./script/…/config/…/vendor/rails/railties/lib/webrick_server.rb:67:in
`dispatch’
./script/…/config/…/vendor/rails/railties/lib/commands/servers/webrick.rb:59
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in
`require__’
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in
`require’
./script/…/config/…/vendor/rails/activesupport/lib/active_support/dependencies.rb:147:in
`require’
./script/…/config/…/vendor/rails/railties/lib/commands/server.rb:30
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in
`require__’
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in
`require’
script/server:3