ActiveAdmin on Heroku (Rails 3.1)

I wrote a post detailing some issues I had with ActiveAdmin and Heroku with Rails 3.1.

It’s probably entirely out of date, but in case its of any use for you, it’s still archived here.

Just a brief note on getting the new ActiveAdmin gem working with Heroku under Rails 3.1 (on Thin and probably some other servers too)

ActiveAdmin looks like a really useful tool to avoid Scaffold-itis when it comes to admin interfacing in Rails apps. You install the gem and loosely define what models you’re using; and you can create simple effective dashboards.

It works easily on local testing, but when you deploy to production on Heroku (or locally with thin $ bundle exec rails server thin -e production the build will fail citing /Users/dave/.rvm/gems/ruby-1.9.2-p290/gems/sass-rails-3.1.0/lib/sass/rails/railtie.rb:38:in `block in ': uninitialized constant Sass::Rails::SassTemplate (NameError)… or similar.

By default the SASS gem is defined within ‘assets’ in the Gemfile.  Move the line


group :assets do
gem 'sass-rails', " ~> 3.1.0"
..
end

outside the assets group, and it will spin up without a problem. It seems the assets group is processed after other gems.

Solution found via this post: https://github.com/rails/sass-rails/issues/38
Great introductory ActiveAdmin tutorial at Railscasts

Now to actually build the dashboard…

 

POST UPDATED 2012-02-16

Other issues can be found here: https://github.com/gregbell/active_admin/issues/474 — I was having issues with asset precompile interfering failing with ActiveAdmin (and I’ll admit, a single magic database number value within my codebase).

The solution to this issue was as benatkin pointed out, adding this within the ROUTES file tempers things:

break if ARGV.join.include? 'assets:precompile'

Not sure if it’s good practice but it gets around an annoying conflict with devise and activeadmin.

Edit ends.

  • Alex

    merci!

  • Rok

    Thank you!

  • RalfieRoo

    I love you, man!!

  • http://www.deploymentzone.com Charles Feduke

    You’ve just saved me from hours of frustrating deployments.

  • http://profile.yahoo.com/JD6WICTERN24A4SSLBFBJRAZXY Omais

    ‘m using ActiveAdmin in my application. Reached to the dashboard page but when i have run “rails g active_admin:resource product” command, after that server is not running. I’m using Rails 3.2, Ruby 1.9.2. Can somebody help me… Thanks
    /home/ali/MySite/app/admin/products.rb:1:in `’: uninitialized constant Product (NameError)
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/activeadmin-0.4.3/lib/active_admin/application.rb:161:in `block in load!’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/activeadmin-0.4.3/lib/active_admin/application.rb:161:in `each’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/activeadmin-0.4.3/lib/active_admin/application.rb:161:in `load!’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/activeadmin-0.4.3/lib/active_admin/application.rb:187:in `routes’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/activeadmin-0.4.3/lib/active_admin.rb:78:in `routes’
        from /home/ali/MySite/config/routes.rb:2:in `block in ‘
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/actionpack-3.2.3/lib/action_dispatch/routing/route_set.rb:282:in `instance_exec’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/actionpack-3.2.3/lib/action_dispatch/routing/route_set.rb:282:in `eval_block’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/actionpack-3.2.3/lib/action_dispatch/routing/route_set.rb:260:in `draw’
        from /home/ali/MySite/config/routes.rb:1:in `’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:40:in `block in load_paths’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:40:in `each’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:40:in `load_paths’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:16:in `reload!’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/application.rb:108:in `reload_routes!’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/activeadmin-0.4.3/lib/active_admin/reloader.rb:34:in `reload!’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/activeadmin-0.4.3/lib/active_admin/reloader.rb:61:in `block in attach!’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:429:in `_run__1902147173993390372__prepare__4025180163458367323__callbacks’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:405:in `__run_callback’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:385:in `_run_prepare_callbacks’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:81:in `run_callbacks’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/actionpack-3.2.3/lib/action_dispatch/middleware/reloader.rb:74:in `prepare!’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/actionpack-3.2.3/lib/action_dispatch/middleware/reloader.rb:48:in `prepare!’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/application/finisher.rb:47:in `block in ‘
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `instance_exec’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `run’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/initializable.rb:55:in `block in run_initializers’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `each’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `run_initializers’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/application.rb:136:in `initialize!’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `method_missing’
        from /home/ali/MySite/config/environment.rb:5:in `’
        from /home/ali/MySite/config.ru:4:in `block in ‘
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize’
        from /home/ali/MySite/config.ru:1:in `new’
        from /home/ali/MySite/config.ru:1:in `’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/rack-1.4.1/lib/rack/builder.rb:40:in `eval’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/rack-1.4.1/lib/rack/builder.rb:40:in `parse_file’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/rack-1.4.1/lib/rack/server.rb:200:in `app’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/commands/server.rb:46:in `app’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/rack-1.4.1/lib/rack/server.rb:301:in `wrapped_app’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/rack-1.4.1/lib/rack/server.rb:252:in `start’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/commands/server.rb:70:in `start’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/commands.rb:55:in `block in ‘
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/commands.rb:50:in `tap’
        from /home/ali/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/commands.rb:50:in `’
        from script/rails:6:in `require’    from script/rails:6:in `’

    • http://www.facebook.com/djlowry David Lowry

      Omais

      I’ve found it impossible to successfully start the app with an Admin page named the same as my other models. So rename the Products dashboard ProductAdmin or Potato or Fred… and it should then work.