People,
I can not get validates_with(helloworld-y) rails in my application to work. Read the “callbacks and validators” section of the original RoR manual site and look for stackoverflow, you haven’t found anything.
Here is a stripped-down version of the code that I received after removing everything that could fail.
class BareBonesValidator < ActiveModel::Validator
def validate
end
end
class Unvalidable < ActiveRecord::Base
validates_with BareBonesValidator
end
Sounds like an example tutorial, right? They have a very similar snippet in the RoR guide . Then go to rails consoleand get an ArgumentError when checking for a new record:
ruby-1.9.2-p180 :022 > o = Unvalidable.new
=> #<Unvalidable id: nil, name: nil, created_at: nil, updated_at: nil>
ruby-1.9.2-p180 :023 > o.save
ArgumentError: wrong number of arguments (1 for 0)
from /Users/ujn/src/yes/app/models/unvalidable.rb:3:in `validate'
from /Users/ujn/.rvm/gems/ruby-1.9.2-p180@wimmie/gems/activesupport-3.0.7/lib/active_support/callbacks.rb:315:in `_callback_before_43'
I know I'm missing something, but what?
(NB: In order not to put BareBonesValidatorin a separate file, I left it on top model/unvalidable.rb).