I read this post on
They problem is that the u.save returns true, so it give the impression that all the values got updated. When they did not.
Is there a way to use attr-readonly, but on save
return false if an attribute is read only?
class User < ActiveRecord::Base
attr_accessible :name
attr_readonly :name
end
> User.create(name: "lorem")
> u = User.first
=> #<User id: 1, name: "lorem">
> u.name = "ipsum"
=> "ipsum"
> u.save
=> true
> User.first.name
=> "lorem