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

rails 3.2.0, anyone managed to use Activeadmin? #891

Closed
allaire opened this issue Jan 3, 2012 · 25 comments
Closed

rails 3.2.0, anyone managed to use Activeadmin? #891

allaire opened this issue Jan 3, 2012 · 25 comments

Comments

@allaire
Copy link

allaire commented Jan 3, 2012

I'm stuck on the install, on rake db:migrate, I get:

rake aborted!
An error has occurred, this and all later migrations canceled:

uninitialized constant DeviseCreateAdminUsers::AdminUser

anyone else?

@samvincent
Copy link
Contributor

I read a tweet yesterday from josevalim about devise bugs with rails 3.2 being fixed and released recently.

@allaire
Copy link
Author

allaire commented Jan 4, 2012

I installed devise --pre, and now I get:

undefined local variable or method `paths' for #ActiveAdmin::FileUpdateChecker:0x007fa6a9fea158

doing db:migrate, weird...

@YodaTravis
Copy link

I'm using Rails 3.2, Devise 2.0, and the latest master branch of meta_search

gem 'rails', '3.2.0.rc2'
gem 'devise', '~> 2.0.0.rc'
gem 'activeadmin'
gem 'meta_search', :git => "git@github.com:ernie/meta_search.git"

and I'm getting the same error as @allaire :

$ rake db:migrate --trace
DEPRECATION WARNING: The InstanceMethods module inside ActiveSupport::Concern will be no longer included automatically. Please define instance methods directly in ActiveAdmin::Application instead. (called from <top (required)> at /config/application.rb:7)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
undefined local variable or method 'paths' for #< ActiveAdmin::FileUpdateChecker:0x00000100ce9dd8 >
/activeadmin-0.3.4/lib/active_admin/reloader.rb: 7 :in 'updated_at'
/activesupport-3.2.0.rc1/lib/active_support/file_update_checker.rb:60:in `initialize'

@YodaTravis
Copy link

the problem has nothing to do with rake
running "rails c" causes the same issue

commenting out the active_admin.rb in initializers allows the migrations to run fine (obviously this will cause active admin not to work)

@YodaTravis
Copy link

it looks like in reloader.rb
this:

# Over-ride the default #updated_at to support the deletion of files
def updated_at
  paths.map { |path| File.mtime(path) rescue Time.now }.max
end

should be:

# Over-ride the default #updated_at to support the deletion of files
def updated_at
  @updated_at || begin
    all = []
    all.concat @files.select { |f| File.exists?(f) }
    all.concat Dir[@glob] if @glob
    all.map { |path| File.mtime(path) rescue Time.now }.max || Time.at(0)
  end
end

@allaire
Copy link
Author

allaire commented Jan 6, 2012

Glad to know I'm not the only one. @YodaTravis did you managed to get it working with the reloader.rb fix?

@YodaTravis
Copy link

yes and no
active admin now "works"
but the reloader hack above does not actually reload files
so you can move forward, you just have to restart your server if you change active admin related files
someone who understands the goal of the updated_at method better than I needs to take a look at it

@YodaTravis
Copy link

any one find a better solution to this yet?

@morokhovets
Copy link

i managed it to work with this option
config.reload_classes_only_on_change = false
(when reload_classes_only_on_change is true (default), reloader receives "prepare" callback only once for some unknown reason.)

and this patch

--- a/lib/active_admin/reloader.rb
+++ b/lib/active_admin/reloader.rb
@@ -4,7 +4,9 @@ module ActiveAdmin

     # Over-ride the default #updated_at to support the deletion of files
     def updated_at
-      paths.map { |path| File.mtime(path) rescue Time.now }.max
+      @updated_at || begin
+        (@files||[]).map { |path| File.mtime(path) rescue Time.now }.max || Time.at(0)
+      end
     end

   end
@@ -32,8 +34,7 @@ module ActiveAdmin
     def reload!
       active_admin_app.unload!
       rails_app.reload_routes!
-      file_update_checker.paths.clear
-      watched_paths.each{|path| file_update_checker.paths << path }
+      file_update_checker.instance_variable_set(:@files, watched_paths)
     end

     # Attach to Rails and perform the reload on each request.
@@ -53,7 +54,7 @@ module ActiveAdmin
     end

     def reloader_class
-      if @rails_version[0..2] == '3.1'
+      if @rails_version[0..2] =~ /3\.[^0]/
         ActionDispatch::Reloader
       else
         ActionDispatch::Callbacks

@morokhovets
Copy link

though this patch will not fit for 3.0.x and 3.1.x of course.

@morokhovets
Copy link

anyone else tried this patch?

@zzip
Copy link

zzip commented Jan 19, 2012

@efdi your patch works for me, i added one line and removed the custom FileUpdateChecker, since the default should handle deletion of files as well now. (rails/rails@80256ab)

For me it works now with config.reload_classes_only_on_change = true

Not sure if it's the right approach, i saw it used in the i18n reloader of rails, added with this commit
rails/rails@fa1d9a8

Here is the adapted patch : zzip/active_admin@166cf07

@morokhovets
Copy link

@zzip I'm not sure about removing custom FileUpdateChecker, rails' default implementation has this in rdoc:
# This particular implementation checks for added and updated files,
# but not removed files.

@mperham
Copy link
Contributor

mperham commented Jan 20, 2012

I just removed ActiveAdmin's custom Checker so it works with Rails 3.2. How often do you remove files? I'll restart the server if I do...

@mperham
Copy link
Contributor

mperham commented Jan 20, 2012

See #931

@monde
Copy link

monde commented Jan 21, 2012

I put this duck punch with a reminder in my active admin initializer

config/initializers/active_admin.rb

if ActiveAdmin::VERSION == "0.3.4" && Rails.version == "3.2.0"
  class ActiveSupport::FileUpdateChecker
    def paths
      @files
    end
  end
else
  warn = "!! double check the ActiveSupport::FileUpdateChecker duck punch in #{__FILE__} !!"
  puts "!" * warn.size
  puts warn
  puts "!" * warn.size
end

@jcabas
Copy link

jcabas commented Jan 24, 2012

thanks, it works for me!

@MGPalmer
Copy link

Not for me :(

And IMHO, the ongoing compatibility issues aren't worth the feature of picking up deleted files.

@gregbell
Copy link
Contributor

I just pushed a patch that implements file reloading (without deletions) on master. If there aren't any major issues with Active Admin and Rails 3.2, I will release master as 0.4.0 tomorrow.

@MGPalmer
Copy link

Thanks !

@benmort
Copy link

benmort commented Mar 25, 2012

thanks for the update bundle installed and migrations are working just fine again

@sunnyak247
Copy link

I came across this error when I ran rake db:migrate
uninitialized constant DeviseCreateAdminUsers::AdminUser

How can I solve it please.
Thanks in advance

@pcreux
Copy link
Contributor

pcreux commented Aug 26, 2012

Are you using ActiveAdmin from the master branch?

@sunnyak247
Copy link

No I am not. I am not. Is there anything you think I can do?

@pcreux
Copy link
Contributor

pcreux commented Aug 27, 2012

Could you see if using ActiveAdmin from master solves this issue?

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