around_validation error for Rails4.1.0beta #251

Open
the-teacher opened this Issue May 24, 2013 · 94 comments

Projects

None yet
@the-teacher

Hello!

I have following problem:

Page.last.to_draft
  Page Load (0.2ms)  SELECT "pages".* FROM "pages" ORDER BY "pages"."id" DESC LIMIT 1
   (0.1ms)  begin transaction
   (0.1ms)  rollback transaction
NoMethodError: protected method `around_validation' called for #<StateMachine::Machine:0x00000004382b98>
bin/rails --version
Rails 4.1.0.beta

Maybe it's will be interesting for somebody.

Thank you!

@awsmsrc

I have this too! Its being caused on a machinist .make! call.
Happy to help with more info!

@awsmsrc

any update on this?

@awsmsrc

this is a quick fix, I haven't looked into this more deeply to check for more serious repercussions. With a bit if guidance form a maintainer i'm happy to work on this

@pechorin

bump, same problem on rails (4.1.0.beta)

@nesrual

bump - same problem here using Rails 4.1.0.beta

NoMethodError:
  protected method `around_validation' called for #<StateMachine::Machine:0x007fb0c31c5608>
@WojtekKruszewski

PR from @lukeroberts1990 fixes the problem for me (Rails HEAD)

@the-teacher

Wow wow wow! It's steel doesn't work ((
I can't migrate to rails 4.1.0.beta1

@the-teacher

config/initializers/state_machine_patch.rb

module StateMachine
  module Integrations
     module ActiveModel
        public :around_validation
     end
  end
end
@sid137

@the-teacher Thanks! works great

@JuriKern

It's not worked for me, because same error for :around_save protected method (rails 4.1.0.beta1).
Issue (config/initializers/state_machine_patch.rb):

module StateMachine
  module Integrations
     module ActiveModel
        public :around_validation
     end

     module ActiveRecord
        public :around_save
     end
  end
end
@sid137

@kerny I am on rails edge, and that seems to work

@JuriKern

Seems like a after_transition not works for rails edge (ActiveRecord) to ...

@amacneil

+1

@schaary

+1

@miry

+1

@JuriKern

Last time authored 10 months ago and 19 unresolved pull requests. Very sadly ...

@edbo

@obrie Would be a shame to see state machine go stale, I'm a big fan. Rails is now at v4.1.0rc2 which I reckon means we're pretty close to the release which will make this officially 'broken' soon.

I'm sure some people in the community would be happy to help with maintenance.

@richpeck

Same problem in 4.1.0 stable

@patrickespake

+1
Same problem in 4.1.0 stable.

@cryo28

+1

@the-teacher the-teacher referenced this issue in the-teacher/the_comments Apr 13, 2014
Closed

protected method `around_validation' #25

@klaut

+1

@simonmd

+1

@the-teacher the-teacher referenced this issue in the-teacher/the_role Apr 16, 2014
Closed

Rails 4.1 compatibility #59

@awsmsrc

guys just use AASM (Acts As State Machine), its a shame to see this one go but its had no activity for a while

@hapiben

+1

@crissmancd crissmancd referenced this issue in G5/g5_sibling_deployer_engine Apr 25, 2014
Merged

upgrade rails dependency to 4.1 #13

@Dorian

@the-teacher's comment fixed it for me, thanks, 👍

@jvanbaarsen

@the-teacher Thanks for your comment, worked on rails 4.1!

@miclovich

any chance, we can fork this in its own "state-machine" organization, @pluginaweek is probably extremely busy... this is an awesome gem though.

@dpickett

I propose we create an official fork as this repository has become inactive. I've created a fork and organization here: https://github.com/pluginaweek-statemachine/state_machine

@jvanbaarsen

@dpickett Was the organisation name "state-machine" or "statemachine" already in use? Since thats a bit shorter :D Thanks for the initiative though!

@dpickett

Yeah unfortunately I had very limited options in that department. If anyone has a better idea I am happy to change it. I am also happy to add anyone as a collaborator that had a few changesets in this report, and I am willing to actively maintain this lib, as I use it pretty extensively. I personally loathe aasm so I would like to keep this alive.

@dpickett

hey everyone! I was in touch with Aaron over the weekend to talk about Gem ownership and he was really quick to respond. He noted he needed a little personal time away from the library but he'll be jumping back into it. For more details, please refer to issue #310 - I've deleted my previously created organization and fork.

@miclovich

👍

@Dorian

@dpickett I think an organization with multiple commiters would be a better and safer idea, even Aaron would agree with that, he would still one of the maintainer if he wants to

@cheshire137

Still an issue on Rails 4.1.1.

@bobbus

@dpickett , I would agree with @Dorian : there is no commit on this project since 1 year, this really looks like an abandoned project and it would probably prevent new user to choose this gem.

@JohnSmall

This is a showstopper in Rails 4.1.1.

Is anyone taking a look at it?

@marcusg

+1

@annapetry

I was getting the "NoMethodError....blah blah blah...protected method :around_validation..."

The error was happening in this file:

/Users/[USERNAME]/.rvm/gems/ruby-2.1.1@global/gems/activerecord-4.1.0/lib/active_record/callbacks.rb

So I just went in there and made the following method public:

def create_or_update #:nodoc:
run_callbacks(:save) { super }
end

Not sure that this is a good idea, but it worked. I have the functionality I was looking for.

@the-teacher the-teacher referenced this issue in the-teacher/the_comments Jun 23, 2014
Closed

Error 500 returned when commenting #27

@malditojavi

I'm testing the fix suggested by @annapetry, but I have no idea where to include my edit and what to include. My issue is not in the active record, but in the active support folder, I have uploaded the file in this gist if anyone can help - https://gist.github.com/malditojavi/dca63c7308808cf77f91

The issue is returning in the log is:

NoMethodError - protected method around_validation' called for #<StateMachine::Machine:0x00000102676440>:
activesupport (4.1.1) lib/active_support/callbacks.rb:447:in
block in make_lambda'
activesupport (4.1.1) lib/active_support/callbacks.rb:298:in block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:86:in
run_callbacks'
activemodel (4.1.1) lib/active_model/validations/callbacks.rb:111:in run_validations!'
activemodel (4.1.1) lib/active_model/validations.rb:317:in
valid?'

@seuros

@malditojavi
Use my fork, if there is a problem there, i will fix it for you.

@malditojavi

@seuros Worked great along the fix from @the-teacher, thanks both

@seuros

I don't think you need the patch.

@malditojavi

True, @seuros I didn't tested it without it, but it works

@zdavis

+1

@gorokhovich

@seuros a huge thanks to you, hope author will fix it

@thb
thb commented Jul 6, 2014

+1

@creasty

+1

@naserca

+1

@derrek

+1

@the-teacher

Hello!

Today I decide - my gem TheComments will provide patch for StateMachine. I hope it will be helpful

https://github.com/the-teacher/the_comments/blob/master/lib/the_comments.rb#L24

if StateMachine::VERSION.to_f <= 1.2
puts '~' * 50
puts 'TheComments'
puts '~' * 50
puts 'WARNING!'
puts 'StateMachine patch for Rails4 will be applied'
puts
puts '> private method *around_validation* from StateMachine::Integrations::ActiveModel will be public'
puts
puts 'https://github.com/pluginaweek/state_machine/issues/295'
puts 'https://github.com/pluginaweek/state_machine/issues/251'
puts '~' * 50

module StateMachine::Integrations::ActiveModel
   public :around_validation
end

end

Simple patch still actual for rails 4.1.X

You can use it for any project which use StateMachine

module StateMachine::Integrations::ActiveModel
   public :around_validation
end
@arojoal

+1

@jasdeepsingh

Issue exists for Rails 4.2.0.beta1 too.

@lvl0nax

+1

@maokomioko

Maybe instead of continuously stamping +1, we can create a community fork and finally keep on with the development?

@awsmsrc

we've been asked not to by a friend of @pluginaweek, i recommend using aasm in the meantime

@yordis

+1

Rails 4.1.4
Ruby 2.1.1

@arnaudbouffard

@the-teacher's comment with state_machine_patch.rb worked for me, thanks!
rails, '4.1.5'
ruby '2.1.1'

@lucascaton

@pluginaweek: any news on this one? Any change to bump the version with the fix?
Thanks.

@djedynak

Hi, can someone please explain how to install @the-teacher's patch?

@gingermusketeer

@djedynak I added a file config/initializers/state_machine_patch.rb to my rails app with the contents

#See https://github.com/pluginaweek/state_machine/issues/251
module StateMachine
  module Integrations
     module ActiveModel
        public :around_validation
     end
  end
end

If you put @the-teacher's patch into that file instead it should do the trick as well

@Andrekra

+1

@mhuggins

+1 (cause my +1 is obviously going to make this happen compared to everyone else's 😄)

@nhoffmann

Thank you @mhuggins for making it happen 😛

@chriswoodrich

+1 for @djedynak 's fix

@warpc

+1 for @the-teacher 's fix

@keithgordon

Thank you @the-teacher for the fix

@nhoffmann

If it has not come to your attention yet, there is a maintained fork of this project by @seuros,
which is probably a better solution than to monkeypatch this abandoned project.

https://github.com/state-machines/state_machines

@keithgordon
@thatandyrose

thank you @seuros and @nhoffmann, just saved my bacon! :-)

@andrii

+1

@jerome2

@the-teacher :
thanks for your patch. It was really simple to apply and offer a real solution in case of use your (really good) gems files.

@catmando

word to the wise, while its great that somebody is supporting state_machine, it is not 100% the same behavior as the old state_machine gem... I suspect there were bugs in the old version that have been fixed. At any rate, you might find during the upgrade the quickest fix is the monkey patch.

@akonan

+1

@sennor

+1

@rvsingh

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment