pluginaweek / state_machine

Adds support for creating state machines for attributes on any Ruby class
http://www.pluginaweek.org
MIT License
3.74k stars 507 forks source link

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

Closed seuros closed 9 years ago

seuros commented 10 years ago
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 commented 10 years ago

+1

seuros commented 10 years ago

@marclennox , you can use my fork for now .

marclennox commented 10 years ago

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/pluginaweek/state_machine/issues/295#issuecomment-31186348 .

hayesr commented 10 years ago

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 10 years ago

:+1:

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 commented 10 years ago

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

nthj commented 10 years ago

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

seuros commented 10 years ago

I see :+1:

MSch commented 10 years ago
# 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 commented 10 years ago

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: https://github.com/pluginaweek/state_machine/issues/295#issuecomment-37096861

marclennox commented 10 years ago

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 10 years ago

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.

gucki commented 10 years ago

Hm I wonder if this gem is still maintained? :-1:

marclennox commented 10 years ago

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: :-1:]

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

fredngo commented 10 years ago

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 commented 10 years ago

Just ran into this issue. Has this been fixed?

charliemaffitt commented 10 years ago

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

tanelsuurhans commented 10 years ago

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

charliemaffitt commented 10 years ago

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

kovpack commented 10 years ago

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

rusikf commented 10 years ago

problem is stil exists, fork from seuros helped

styledev commented 10 years ago

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

vickodin commented 10 years ago

@MSch :+1:

phlegx commented 10 years ago

@MSch :+1: super man...

mikebaldry commented 10 years ago

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

alienatix commented 10 years ago

+1, please fix this issue.

jaredbeck commented 10 years ago

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

seuros commented 10 years ago

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

jaredbeck commented 10 years ago

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

Thanks, I'll check it out!

fabioperrella commented 10 years ago

+1

the-teacher commented 10 years ago

https://github.com/pluginaweek/state_machine/issues/251

leckylao commented 9 years ago

@MSch :+1:

korun commented 9 years ago

This problem is actual for Rails 4.1.1 too!

gemtainers commented 9 years ago

Have an idea about mainaining #331

JohnSmall commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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

seuros commented 9 years ago

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