pluginaweek/state_machine

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

seuros opened this issue ยท 38 comments

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 , you can use my fork for now .

Awesome thanks!

On 24 December 2013 17:12, Abdelkader Boudih notifications@github.comwrote:

@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
.

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 commented

๐Ÿ‘

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

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

nthj commented

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

I see ๐Ÿ‘

MSch commented
# 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

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 notifications@github.com
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)

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 commented

Nice, I did not know about public :method_name

On March 8, 2014 at 10:18:18 AM CST, Marc Lennox notifications@github.com 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.

Hm I wonder if this gem is still maintained? ๐Ÿ‘Ž

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 notifications@github.com 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
.

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.

Just ran into this issue. Has this been fixed?

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

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

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

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

problem is stil exists, fork from seuros helped

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

@MSch ๐Ÿ‘

@MSch ๐Ÿ‘ super man...

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

+1, please fix this issue.

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

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

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

Thanks, I'll check it out!

@MSch ๐Ÿ‘

This problem is actual for Rails 4.1.1 too!

Have an idea about mainaining #331

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.

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?

@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)

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