Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoMethodError: protected method `around_validation' in Rails 4.1.0.beta1 #295

Closed
seuros opened this issue Dec 20, 2013 · 38 comments
Closed

Comments

@seuros
Copy link

seuros commented Dec 20, 2013

Store.first.save
  Store Load (0.9ms)  SELECT  "stores".* FROM "stores"   ORDER BY created_at LIMIT 1
   (0.2ms)  BEGIN
   (0.1ms)  ROLLBACK
NoMethodError: protected method `around_validation' called for #<StateMachine::Machine:0x007f674cc70f78>

The model has just statemachine

  belongs_to :vendor
  state_machine :state, :initial => :new do
  end
@marclennox
Copy link

+1

@seuros
Copy link
Author

seuros commented Dec 24, 2013

@marclennox , you can use my fork for now .

@marclennox
Copy link

Awesome thanks!

On 24 December 2013 17:12, Abdelkader Boudih [email protected]:

@marclennox https://github.com/marclennox , you can use my fork for now
.


Reply to this email directly or view it on GitHubhttps://github.com//issues/295#issuecomment-31186348
.

@hayesr
Copy link

hayesr commented Feb 1, 2014

I can confirm that moving around_validation out from under protected works in Rails 4.1 beta1. Also, tests pass for state_machine. (didn't run appraisals)

@nthj
Copy link

nthj commented Feb 19, 2014

👍

If you'd like a quick hack, I threw this in my initializers:

# Rails 4.1.0.rc1 and StateMachine don't play nice

require 'state_machine/version'

unless StateMachine::VERSION == '1.2.0'
  # If you see this message, please test removing this file
  # If it's still required, please bump up the version above
  Rails.logger.warn "Please remove me, StateMachine version has changed"
end

module StateMachine::Integrations::ActiveModel
  alias_method :around_validation_protected, :around_validation
  def around_validation(*args, &block)
    around_validation_protected(*args, &block)
  end
end

@seuros
Copy link
Author

seuros commented Feb 19, 2014

Why will you put this the initializer without checking manually that the version correct ?

@nthj
Copy link

nthj commented Feb 19, 2014

It's more for when state_machine fixes the problem upstream, I'll get a notice in my logs to remove the monkeypatch.

@seuros
Copy link
Author

seuros commented Feb 19, 2014

I see 👍

@MSch
Copy link

MSch commented Mar 8, 2014

# Rails 4.1.0.rc1 and StateMachine don't play nice
# https://github.com/pluginaweek/state_machine/issues/295

require 'state_machine/version'

unless StateMachine::VERSION == '1.2.0'
  # If you see this message, please test removing this file
  # If it's still required, please bump up the version above
  Rails.logger.warn "Please remove me, StateMachine version has changed"
end

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

works for me and is less hacky

@marclennox
Copy link

Yeah I have a fork of state machine I'm using until the author fixes it.  I'll send you later—
Sent from Mailbox for iPhone

On Sat, Mar 8, 2014 at 7:53 AM, Martin Schürrer [email protected]
wrote:

# Rails 4.1.0.rc1 and StateMachine don't play nice
# https://github.com/pluginaweek/state_machine/issues/295
require 'state_machine/version'
unless StateMachine::VERSION == '1.2.0'
  # If you see this message, please test removing this file
  # If it's still required, please bump up the version above
  Rails.logger.warn "Please remove me, StateMachine version has changed"
end
module StateMachine::Integrations::ActiveModel
  public :around_validation
end

works for me and is less hacky

Reply to this email directly or view it on GitHub:
#295 (comment)

@marclennox
Copy link

Sorry ignore my last comment... I'm using State Machine with 4.1rc1 using your recommend monkey patch and it's working great for me.

@nthj
Copy link

nthj commented Mar 8, 2014

Nice, I did not know about public :method_name

On March 8, 2014 at 10:18:18 AM CST, Marc Lennox [email protected] wrote:Sorry ignore my last comment... I'm using State Machine with 4.1rc1 using your recommend monkey patch and it's working great for me. —Reply to this email directly or view it on GitHub.

@gucki
Copy link

gucki commented Apr 13, 2014

Hm I wonder if this gem is still maintained? 👎

@marclennox
Copy link

I've been wondering the same thing. Would be a shame if not, this is a
really good gem and much better than the alternatives.

On 13 April 2014 10:02, Corin Langosch [email protected] wrote:

Hm I wonder if this gem is still maintained? [image: 👎]


Reply to this email directly or view it on GitHubhttps://github.com//issues/295#issuecomment-40308256
.

@fredngo
Copy link

fredngo commented May 2, 2014

Yes, I still prefer this gem to the Active Record enums in Rails 4.1.
+1 here, will use the hack until there is an update.

@saurabhnanda
Copy link

Just ran into this issue. Has this been fixed?

@charliemaffitt
Copy link

Not that I know of. I'm using the hack still.

@tanelsuurhans
Copy link

What's the holdup with this fix? Seems to be a rather straightforward issue, no?

@charliemaffitt
Copy link

I doubt the gem is actively maintained, folks. This looks like abandonware to me.

@kovpack
Copy link

kovpack commented Jun 21, 2014

I've got the same problem. Now I think of removing it from my gem list, however, gem is cool. That is sad :(

kcurtin added a commit to trilogy-group/contently-has_messages that referenced this issue Jun 25, 2014
kcurtin added a commit to trilogy-group/contently-has_messages that referenced this issue Jun 25, 2014
@rusikf
Copy link

rusikf commented Jul 9, 2014

problem is stil exists, fork from seuros helped

@styledev
Copy link

styledev commented Jul 9, 2014

It would be nice if the original developer would fix this one small issue...

@vickodin
Copy link

@MSch 👍

@phlegx
Copy link

phlegx commented Jul 26, 2014

@MSch 👍 super man...

@mikebaldry
Copy link

really this is still not fixed? Time for a new SM gem that is maintained?

@alienatix
Copy link

+1, please fix this issue.

johnnaegle added a commit to GoodMeasuresLLC/state_machine that referenced this issue Jul 30, 2014
okeefm pushed a commit to okeefm/cypress that referenced this issue Jul 31, 2014
@jaredbeck
Copy link

Thanks, @MSch. That will tide my team over until we can switch to a fork or a different library.

@seuros
Copy link
Author

seuros commented Jul 31, 2014

@jaredbeck , you can use my fork. It has all fixes and many people are using it.

@jaredbeck
Copy link

@jaredbeck , you can use my fork. It has all fixes and many people are using it.

Thanks, I'll check it out!

@fabioperrella
Copy link

+1

@the-teacher
Copy link

#251

ugoa pushed a commit to ugoa/state_machine that referenced this issue Sep 19, 2014
# Rails 4.1.0.rc1 and StateMachine don't play nice
# pluginaweek#295
@leckylao
Copy link

@MSch 👍

mfenner pushed a commit to mfenner/lagotto that referenced this issue Nov 3, 2014
@korun
Copy link

korun commented Nov 12, 2014

This problem is actual for Rails 4.1.1 too!

@gemtainers
Copy link

Have an idea about mainaining #331

@JohnSmall
Copy link

Mm, I've been using the forked version (seuros above) for sometime in 4.1.x and it's working fine. In 4.2 it fails utterly. I'm trying to look into now as I have a project to finish soon. But I think my work around will be to maintain state myself until I get a chance to dive into it.

@davidcpell
Copy link

getting this problem on Rails 4.2, looks like @seuros' fork now works for that! thanks @seuros! any plans to take over maintenance of the gem?

@seuros
Copy link
Author

seuros commented Jan 17, 2015

@davidcpell : https://github.com/state-machines/state_machines-activerecord, there is just 1 small bug in 4.2. (initial state is not persisted, but can be worked around by either setting the default in the column or having a before_create callback)

albertosaurus added a commit to HornsAndHooves/enum_state_machine that referenced this issue Jan 20, 2015
@seuros
Copy link
Author

seuros commented Jan 21, 2015

@JohnSmall unless you are using Mongoid or another integrations, can you check if SM-AR works for you ?

@seuros seuros closed this as completed Feb 4, 2015
romansklenar added a commit to martincik/rails-insights that referenced this issue May 4, 2015
Rails 4.1+ and StateMachine don't play nice, see pluginaweek/state_machine#295 for more info
andrewmacgregor pushed a commit to agworld/state_machine that referenced this issue Feb 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests