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

problem when associated class is using devise #21

Open
AlperKarapinar opened this issue Feb 3, 2011 · 10 comments
Open

problem when associated class is using devise #21

AlperKarapinar opened this issue Feb 3, 2011 · 10 comments

Comments

@AlperKarapinar
Copy link

Hello,

I m getting method_missing for 'devise' method error when i try to archive a class which belongs to another devise class. When i comment out the association line everything is ok. How can i fix this? Thanks..

@elmatou
Copy link
Collaborator

elmatou commented Feb 11, 2011

Same issue.

@AlperKarapinar
Copy link
Author

Its sad that i had to give up trying to fix this. We were working on an urgent project last week. I will try fix this issue as soon as i ll have time. Thank you for your great work. Loved this gem.

@aaronchi
Copy link

:(

@elmatou
Copy link
Collaborator

elmatou commented Mar 2, 2011

@winton (or anybody who want to help).

I'ill be glad to help in solving this issue.
here under a summarized trace of the app.

=> Rails 2.3.11 application starting on http://0.0.0.0:3000
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.11/lib/active_record/base.rb:1998:in `method_missing': undefined method `devise' for # (NoMethodError)
        from /home/marc-antoine/Developpement/RailsProjects/ako/app/models/user.rb:56
        from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.11/lib/active_support/dependencies.rb:406:in `load_without_new_constant_marking'
.........
        from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.11/lib/active_support/dependencies.rb:124:in `const_missing'
        from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.11/lib/active_record/base.rb:2234:in `compute_type'
        from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.11/lib/active_record/reflection.rb:156:in `send'
        from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.11/lib/active_record/reflection.rb:156:in `klass'
        from /usr/lib/ruby/gems/1.8/gems/acts_as_archive-0.4.0/lib/acts_as_archive.rb:130:in `acts_as_archive'
        from /usr/lib/ruby/gems/1.8/gems/acts_as_archive-0.4.0/lib/acts_as_archive.rb:129:in `each'
        from /usr/lib/ruby/gems/1.8/gems/acts_as_archive-0.4.0/lib/acts_as_archive.rb:129:in `acts_as_archive'
        from /usr/lib/ruby/gems/1.8/gems/acts_as_archive-0.4.0/lib/acts_as_archive.rb:56:in `load_from_yaml'
        from /usr/lib/ruby/gems/1.8/gems/acts_as_archive-0.4.0/lib/acts_as_archive.rb:55:in `each'

It seems AAA (acts_as_archive) load the Activerecord model before all the required method (here is a gem, Devise)
a workaround could be to check in the model if the library is defined.. not very fancy, and quite obtrusive
Other way could be to rescue in AAA all errors that could append during the loading... Not very safe

The only good solution is IMHO to ensure AAA is the last resource loaded in the app.
But I didn't figure out to do this (old Rails loading process or Bundler)

@elmatou
Copy link
Collaborator

elmatou commented Mar 15, 2011

Hi everybody,
I fixed this issue, but it chunk the loading process.
Anybody with this issue would want to see my fork : https://github.com/elmatou/acts_as_archive/tree/manual-loading
check the readme for explanation. (this fork fix also issue 24)

@jnimety
Copy link

jnimety commented Mar 22, 2011

You can also try the following if using Rails 3. This gets around the method missing issue but I'm now getting other errors (Possibly related to STI, still investigating)

in Gemfile:
gem 'acts_as_archive', :require => nil

in config/initializers/acts_as_archive.rb
Rails.application.config.after_initialize do
require 'acts_as_archive'
end

@elmatou
Copy link
Collaborator

elmatou commented Mar 22, 2011

Hi Joel,
This did'nt worked for me (R1.8.9, r2.3.11+ Bundler ) that is why I forked the gem.
It looks like Bundler require the lib even when :require => nil is passed.
there is a common issue with polymorphic assocation maybe it is yours.
issue 24 + patch : #26

@jnimety
Copy link

jnimety commented Mar 25, 2011

Thanks elmatou, indeed it was the polymorphic association issue.

@divineforest
Copy link

:require => nil works for me. Rails 3

This was referenced Oct 19, 2011
@GAV1N
Copy link

GAV1N commented Jan 10, 2012

@winton, can you merge elmatou's changes into master?

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

6 participants