I set up session to save to the db and everytime I hit a page I get a
new session entry created. Some of them have session_ids of more than 5
digits, but lots of them have session_ids like 0.
Something is amiss.
I set up session to save to the db and everytime I hit a page I get a
new session entry created. Some of them have session_ids of more than 5
digits, but lots of them have session_ids like 0.
Something is amiss.
I built a test application and get the same behavior. I cannot find any
documentation of this bug so I assume I’ve done something wrong.
I did follow the instructions in ‘Agile Web D. with Rails’ step
by step though.
can you paste the lines from environment.rb that you changed to put
sessions
in the DB ?
How did you create your session table in the DB ?
adam
config.action_controller.session_store = :active_record_store
class AddSessions < ActiveRecord::Migration
def self.up
create_table :sessions do |t|
t.column :session_id, :string
t.column :data, :text
t.column :updated_at, :datetime
end
add_index :sessions, :session_id
end
def self.down
drop_table :sessions
end
end
Here is the code in my controller that gets called often to store a
Score object to the session:
private
def find_score
session[:score] ||= Score.new
end
Here is my Score object:
class Score
include Reloadable
attr_reader :point_ids, :logged_test_id
def initialize
@point_ids = []
@logged_test_id
end
def set_logged_test_id(logged_test_id)
@logged_test_id = logged_test_id
end
def add_point_id(point_id)
@point_ids << point_id
end
end
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs