how to fetch value of a column which has some default value rails mysql -


i had user model, attributes email, name ... wanted add column has_agreed default value true. added migration , ran it, shows in database. when fetch value, @user.has_agreed, not return me value. have written has_agreed in attribute accessible (rails 3.2). if manually change contents of database update command particular user change has_agreed value false user id 1 , run same call, @user.has_agreed, returns false.

i have historical data , want add default column , can not , not intend manually update column through database. how value?

also, issue old users in user table. new users works fine.

in user.rb

class user def has_agreed # use line code. if has_agreed not equal false # read_attribute(:has_agreed) || default_velue if read_attribute(:has_agreed).blank? ## default value true else read_attribute(:has_agreed) end end end


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -