Ah that makes perfect sense. So here's what I did: $accounts.where(:name => account_name).first.update(:current_login => @user)
But it doesn't change? Does that mean .update requires a whole hash to replace the previous one? I didn't think that's how it worked. On Jan 10, 9:58 am, Jeremy Evans <[email protected]> wrote: > On Jan 10, 6:03 am, ThinkWriteMute <[email protected]> wrote: > > > > > > > So as you can see below: > > > {:id=>1, :name=>"test", :password=>"test", :alias_array=>nil, > > :stream_array=>nil, :login_hash=>"1263130262", > > :current_login=>"127.0.0.1:52815"} > > {:id=>1, :name=>"test", :password=>"test", :alias_array=>nil, > > :stream_array=>nil, :login_hash=>"1263130262", > > :current_login=>"127.0.0.1:39890"} > > {:id=>1, :name=>"test", :password=>"test", :alias_array=>nil, > > :stream_array=>nil, :login_hash=>"1263130262", > > :current_login=>"127.0.0.1:52815"} > > > I have a SQLite database that refuses to make the changes > > to :current_login permanent. > > > Why is this? > > p $account.all ... > > # > > {:id=>1, :name=>"test", :password=>"test", :alias_array=>nil, > > :stream_array=>nil, :login_hash=>"1263130262", > > :current_login=>"127.0.0.1:52815"} > > account = $accounts.where(:name => account_name).first > > account.update(:current_login => @user) > > p account > > # > > {:id=>1, :name=>"test", :password=>"test", :alias_array=>nil, > > :stream_array=>nil, :login_hash=>"1263130262", > > :current_login=>"127.0.0.1:39890"} > > p $account.all ... > > # > > {:id=>1, :name=>"test", :password=>"test", :alias_array=>nil, > > :stream_array=>nil, :login_hash=>"1263130262", > > :current_login=>"127.0.0.1:52815"} > > Assuming $accounts is a dataset, the problem is that account is a hash > and therefore account.update is just Hash#update, which doesn't modify > the database. Either use models (in which case account.update will > modify the database), or do $accounts.where(:id=>account[:id]).update > (account) to do the update. > > Jeremy
-- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en.
