Stack level too deep w/ railroad
-
Courtenay
I'm seeing this too. Going to try and get a failing testcase.
-
Courtenay
I don't run railroad..
-
Courtenay
Appears to be an issue with this code [active_record_persistence.rb:238]
module NamedScopeMethods def aasm_state_with_named_scope name, options = {} aasm_state_without_named_scope name, options self.named_scope name, :conditions => {self.aasm_column => name.to_s} unless self.respond_to?(name) end endIf I add this, it makes the problem go away. Not entirely sure if it breaks my code, yet.:
module NamedScopeMethods def aasm_state_with_named_scope name, options = {} + return send(name, options) if respond_to?(name) aasm_state_without_named_scope name, options self.named_scope name, :conditions => {self.aasm_column => name.to_s} unless self.respond_to?(name) end end -
Dave Nolan
- Tag set to persistance, railroad, rspec, stack-level
Not sure blame lies with AASM here.
It's not just Railroad, it's anytime that ActiveRecordPersistance is being included more than once in the same class.
For example:
class Bar < ActiveRecord::Base end describe Bar do # # setup/teardown table # before(:all) do ActiveRecord::Base.connection.instance_eval do drop_table(:bars) if table_exists?(:bars) create_table(:bars) do |t| t.datetime :aasm_state end end end after(:all) do ActiveRecord::Base.connection.instance_eval { drop_table(:bars) if table_exists?(:bars) } end it "should not raise an error when including AASM more than once" do Bar.send(:include, AASM) Bar.send(:aasm_state, :alpha) lambda { Bar.send(:include, AASM); Bar.send(:aasm_state, :alpha) }.should_not raise_error end endThis will fail because ActiveRecordPersistence alias_method line 46, 47 become circular on second inclusion.
Either manually
undef_methodthe aasm_named_scope methods before including AASM in your class,or patch
active_record_persistance.rbfrom line 44 like this:base.class_eval do
class << self- unless defined_method? :aasm_state_without_named_scope
alias_method :aasm_state_without_named_scope, :aasm_state alias_method :aasm_state, :aasm_state_with_named_scope -
end end end
-
Courtenay
This patch works for me, it seems.. except it's method_defined?, not defined_method?
-
Courtenay
There's something in newer versions of rails that fucks with AASM. You also have to do something like
include AASM unless defined?(AASM)in your models :( otherwise your states get cleared. Empty states. weird.
-
Stuart Piltch
It looks like some of the recent "stack level too deep" problems are related to the new facets. With facets 2.6.0, I get this:
SystemStackError: stack level too deep facets (2.6.0) lib/core/facets/kernel/state.rb:4:in `state' facets (2.6.0) lib/core/facets/kernel/state.rb:4:in `state' /opt/local/lib/ruby/gems/1.8/gems/rubyist-aasm-2.1.1/lib/aasm/persistence/active_record_persistence.rb:235:in `send' /opt/local/lib/ruby/gems/1.8/gems/rubyist-aasm-2.1.1/lib/aasm/persistence/active_record_persistence.rb:235:in `aasm_read_state' /opt/local/lib/ruby/gems/1.8/gems/rubyist-aasm-2.1.1/lib/aasm/persistence/active_record_persistence.rb:137:in `aasm_current_state' /opt/local/lib/ruby/gems/1.8/gems/rubyist-aasm-2.1.1/lib/aasm/aasm.rb:49:in `complete?'When I downgrade to facets 2.5.2, the problem goes away.
-
rubyist
Howdy - are you guys experiencing this with the latest from my master (7a1c)?
-
Stuart Piltch
are you guys experiencing this with the latest from my master (7a1c)?
Using the 2.1.1 gem from gems.github.com (not sure how to tell which git commit it's based on):
- with facets 2.5.2: no error
- with facets 2.6.0: SystemStackError: stack level too deep
(lib/core/facets/kernel/state.rb:4:in
state') - with facets 2.7.0: no error
Using "git clone git://github.com/rubyist/aasm.git" (7a1c) into vendor/plugins (and the gem uninstalled):
- with facets 2.5.2: no error
- with facets 2.6.0: SystemStackError: stack level too deep
(lib/core/facets/kernel/state.rb:4:in
state') - with facets 2.7.0: no error
-
Travis Tilley
this should be fixed in master:
def self.included(base) base.extend AASM::Persistence::ActiveRecordPersistence::ClassMethods base.send(:include, AASM::Persistence::ActiveRecordPersistence::InstanceMethods) base.send(:include, AASM::Persistence::ActiveRecordPersistence::ReadState) unless base.method_defined?(:aasm_read_state) base.send(:include, AASM::Persistence::ActiveRecordPersistence::WriteState) unless base.method_defined?(:aasm_write_state) base.send(:include, AASM::Persistence::ActiveRecordPersistence::WriteStateWithoutPersistence) unless base.method_defined?(:aasm_write_state_without_persistence) if base.respond_to?(:named_scope) base.extend(AASM::Persistence::ActiveRecordPersistence::NamedScopeMethods) base.class_eval do class << self unless method_defined?(:aasm_state_without_named_scope) alias_method :aasm_state_without_named_scope, :aasm_state alias_method :aasm_state, :aasm_state_with_named_scope end end end end base.before_validation_on_create :aasm_ensure_initial_state end -
Simple Jack
I'm having the same issue, can someone please resolve this issue. I cannot work on my PC with this error keeps popping out. I have searched online but still haven't found any solution to this SystemStackError. I even asked in forums about this and they don't know the answer either. II'll just play Harry Potter Hogwarts mystery PC while waiting for some answers.
Let you kids play gacha club on pc or mobile. It is free to download.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.