grouped_validations icon indicating copy to clipboard operation
grouped_validations copied to clipboard

Rails 4 undefined method `_run_validate_#{group}_callbacks' for #<Quote:0x00000101da89a8>

Open peterbeers opened this issue 11 years ago • 4 comments

Rails 4.0.1 Ruby 2.0.0-p247

I defined a group called :offer in my Quote model.

validation_group :offer do validates_presence_of :initials end

When I start the console and test the following:

[1] pry(main)> q = Quote.new [2] pry(main)> q.valid? NoMethodError: undefined method _run_validate_offer_callbacks' for #<Quote:0x00000101da89a8> from /Users/peter/.rvm/gems/ruby-2.0.0-p247/gems/activemodel-4.0.1/lib/active_model/attribute_methods.rb:439:inmethod_missing'

Same happens for q.groups_valid?(:offer)

I noticed that it works when you replace: send(:"_run_validate_#{group}_callbacks") with: run_callbacks(:"validate_#{group}")

But I don't know if it's the proper way.

peterbeers avatar Nov 13 '13 16:11 peterbeers

@peterbeers Did you find out if this is a proper way to fix these errors?

sajoku avatar Sep 03 '14 09:09 sajoku

@sajoku No, I never did. I'm using the reform gem now.

peterbeers avatar Sep 03 '14 09:09 peterbeers

It might be the old topic, however I managed to force it (proper word) to work with rails 4.1+ - https://github.com/BroiSatse/grouped_validations

BroiSatse avatar Apr 28 '15 01:04 BroiSatse

BroiSatse, thank you, it does work with Rails 4.2.4...

Here is a link to the changes made to the actual gem: https://github.com/BroiSatse/grouped_validations/commit/49f634a655391aade53870ab4e7091d6605c2208

marklohr avatar Sep 16 '15 18:09 marklohr