レール初心者。次の例score > 50
ではなく、なぜ使用するのか理解できません。記号は、クラスで使用する必要があるインスタンス変数を意味@score > 50
しませんか?@
クラスはどこscore
から変数を取得していますか? @
?が前に付いていなければ、ローカルと見なされるという印象を受けました。
class HighScore < ActiveRecord::Base
attr_accessible :game, :score
validate :verify_inputs
def verify_inputs
# Why is this line not @score > 50??
if score > 50
errors.add( :score, 'Custom error message. Score cannot be more than 50' )
end
end
end