Hello, I have an old table that handles sessions. the primary key is a field called session_id and is the actual session id like "8df838303ufdfu838" however when i do the following in the model: set_primary_key "session_id" and the following in the controller: @session_hash = { "session_id" => @session.session_id, "session_user_id" => @entry.user_id, "session_ip" => encode_ip, "session_time" => Time.now } it wont update the session_id as noted here in script/console:>> sess = Session.new=> #<Session:0x407683f0 @attributes={"session_start"=>0, "session_time"=>0, "session_ip"=>"0", "session_admin"=>0, "session_page"=>0, "session_logged_in"=>false, "session_user_id"=>0}, @new_record=true>>> sess.session_id=> nil>> sess.session_id = ''3893839393''NoMethodError: undefined method `session_id='' for #<Session:0x407683f0> from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:1498:in `method_missing'' from (irb):3 How do i enable manually setting the session_id value ? If i comment out the "set_primary_key" line everything seems to break. adam -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060309/8c57669b/attachment.html
Adam Denenberg wrote:> Hello, > > I have an old table that handles sessions. the primary key is a field > called session_id and is the actual session id like "8df838303ufdfu838" > > however when i do the following in the model: > set_primary_key "session_id" > > and the following in the controller: > > @session_hash = { "session_id" => @session.session_id, > "session_user_id" => > @entry.user_id, "session_ip" => encode_ip, "session_time" => Time.now } > > it wont update the session_id as noted here in script/console: > >>> sess = Session.new > => #<Session:0x407683f0 @attributes={"session_start"=>0, > "session_time"=>0, > "session_ip"=>"0", "session_admin"=>0, "session_page"=>0, > "session_logged_in"=>false, "session_user_id"=>0}, @new_record=true> >>> sess.session_id > => nil >>> sess.session_id = ''3893839393'' > NoMethodError: undefined method `session_id='' for #<Session:0x407683f0> > from > /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:1498:in > `method_missing'' > from (irb):3 > > > How do i enable manually setting the session_id value ? If i comment out > the > "set_primary_key" line everything seems to break. > > adamEven though you set_primary_key, you still use sess.id = ''4543535345'' Joey http://www.feedreed.com -- Posted via http://www.ruby-forum.com/.
thanks. A note on this however.. It seems you cant use a @params hash with "id" as one of the attributes and then do a sess= Session.new(@params). You have to do sess = Session.new(@params) sess.id = somevalue Not sure why but that is the only way i could get it to work. adam On 3/9/06, joey__ <cardologist@gmail.com> wrote:> > Adam Denenberg wrote: > > Hello, > > > > I have an old table that handles sessions. the primary key is a field > > called session_id and is the actual session id like "8df838303ufdfu838" > > > > however when i do the following in the model: > > set_primary_key "session_id" > > > > and the following in the controller: > > > > @session_hash = { "session_id" => @session.session_id, > > "session_user_id" => > > @entry.user_id, "session_ip" => encode_ip, "session_time" => Time.now } > > > > it wont update the session_id as noted here in script/console: > > > >>> sess = Session.new > > => #<Session:0x407683f0 @attributes={"session_start"=>0, > > "session_time"=>0, > > "session_ip"=>"0", "session_admin"=>0, "session_page"=>0, > > "session_logged_in"=>false, "session_user_id"=>0}, @new_record=true> > >>> sess.session_id > > => nil > >>> sess.session_id = ''3893839393'' > > NoMethodError: undefined method `session_id='' for #<Session:0x407683f0> > > from > > /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2 > /lib/active_record/base.rb:1498:in > > `method_missing'' > > from (irb):3 > > > > > > How do i enable manually setting the session_id value ? If i comment out > > the > > "set_primary_key" line everything seems to break. > > > > adam > > Even though you set_primary_key, you still use > sess.id = ''4543535345'' > > Joey > http://www.feedreed.com > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060309/81585eb2/attachment.html