Is it possible to have an attribute that can only be assigned when creating a model object?
For example, the username attribute should be mass assigned when the object is created, but not after it (it should be read-only).
username
This is what attr_readonly does:
attr_readonly
class User < ActiveRecord::Base attr_readonly :username end u = User.create(:username => 'dude') u.username # => 'dude' u.update_attributes(:username => 'dudette') u.reload.username # => 'dude'