attr_accessorにデフォルト値を持たせたいんです
ぐぐると真っ先にattr_accessor_with_default
が出てくるから使ってみたらundefinedって言われた。。
今はこう書くのが正しい。
class Employee < ActiveRecord::Base attr_accessor :a after_initialize do self.last_name = 'tanaka' self.a = 'ito' end end emp = Employee.new p emp.last_name # => "tanaka" p emp.a # => "ito"
(^ω^)にこっ