t.text :name, null: false t.timestamps null: false end end end class CreateUsers < ActiveRecord::Migration[5.0] def change create_table :users do |t| t.text :name, null: false t.timestamps end end end RAILS 4.2 RAILS 5.0 [4.2]
def serialize(value) Encryptor.encrypt(@key, value) if value end def deserialize(value) Encryptor.decrypt(@key, value) if value end def cast(value) value.to_s if value end end