初心者の問題かもしれませんが、そうでないかもしれませんが、OOT が不足しているのかもしれませんが、true に割り当てられたインスタンス変数 @upgrade の値を取得できない理由はまだわかりません。
class OrderTemplate < ActiveRecord::Base
belongs_to :user
attr_writer :upgrade #to hold upgrade process across actions
def upgrade
@upgrade || false
end
def from_time
p self.inspect
------------------------> they looks same
p self.upgrade
------------------------> is true as is supposed to be
p self.user.order_template.inspect
------------------------> they looks same
p self.user.order_template.upgrade
------------------------> is false but i am expecting true
self.user.has_time_bonus?
end
end
class User < ActiveRecord::Base
has_one :order_template
def has_time_bonus?
p self.order_template.upgrade
------------------------> is false but i am expecting true
end
end
叩いてください。