Your call to validates_presence_of addss a validation on the singleton
class of @foo where it will never be executed. You'd need to add the
validation to the class Foo
@foo.class.validates_presence_of :bar
but then it would be active for all instances of Foo in the same
process. Much better to add the validation to the class proper and
guard it with a condition
class Foo < ActiveRecord::Base
validates_presence_of :bar, :if => ...
end