Getting ActiveAdmin and web-app-themes to work with Rail 3.1 at Heroku
(If all you care about is getting Activeadmin to work at Heroku, skip to step 4. If you want to know how to fix scaffolding to the normal rails default after installing ActiveAdmin, skip to step 7.)
Rails 3.1 at Heroku is not quite an “out of the box” deployment.
Part 1. To get started, I recommend http://blog.bryanbibat.net/2011/09/24/starting-a-professional-rails-3-1-app-with-web-app-theme-devise-and-kaminari/
Part 2. If you used the ‘default’ theme for web-app-theme, you need to add a few styles that all the themes except ‘default’ have. Add the following to the end of app/assets/stylesheets/web-app-theme.css:
/* Write here your css for overriding the theme's rules */<br></br>
.small { font-size:.8em; }<br></br>
.gray { color:#999999; }<br></br>
.hightlight { background-color:#FFFFAA; }<br></br>
Since I’m using rails 3.1 I also had to override the stylesheet to use web fonts. So I moved the /app/assets/web-app-theme/theme/default/fonts folder to /public/fonts and copied the @font-face definitions from the default/style.css to app/assets/stylesheets/web-app-theme.css and simply added a “/” in front of the font paths:
@font-face {
font-family: "MuseoSans500";
src: url("/fonts/museosans_500-webfont.eot");
src: local("☺"), url("/fonts/XXXXX.woff") format("woff"), url("/fonts/XXXX.ttf") format("truetype"), url("/fonts/XXXX-webfont.svg#webfontxx") format("svg");
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: "MuseoSans500Italic";
src: url("/fonts/XXXX.eot");
src: local("☺"), url("/fonts/XXXX.woff") format("woff"), url("/fonts/XXXX.ttf") format("truetype"), url("/fonts/XXXX.svg#webfontxxf") format("svg");
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: "Museo700";
src: url("/fonts/XXXX.eot");
src: local("☺"), url("/fonts/XXXX.woff") format("woff"), url("/fonts/XXXXttf") format("truetype"), url("/fonts/XXXX.svg#webfontxx") format("svg");
font-weight: normal;
font-style: normal;
}
Part 3. Add ActiveAdmin, per the excellent tutorial at http://net.tutsplus.com/tutorials/ruby/create-beautiful-administration-interfaces-with-active-admin
There is also a very helpful RailsCast for customizing ActiveAdmin at http://railscasts.com/episodes/284-active-admin
Part 4. Add a fix for Devise at https://github.com/plataformatec/devise/commit/96f55a7ac7a61effd03a7f43dbbdfb6af8894579#diff-1 specifically add to config/application.rb
config.assets.initialize_on_precompile = false<br></br>
I also added
# Enable the asset pipeline<br></br>
config.assets.enabled = true<br></br>
Part 5. Add a fix for ActiveAdmin at https://github.com/gregbell/active_admin/issues/474, specifically, add this to the top of your routes.rb file:
# The ActiveAdmin routes cause Rails to set up a connection to the
# production database, which isn't available during
# assets:precompile on Heroku, so the following unless block skips
# setting up these routes only when rake assets:precompile is
# being run.<br></br>
#
# Could be a problem if the assets needed these to be loaded to
# compile properly; pretty sure they don't.
break if ARGV.join.include? 'assets:precompile'
Part 6. Heroku was still showing a SASS error after I pushed, which was fixed by moving the sass-rails gen OUT of the assets group (eg, move it amongst the regular gems) in the Gemfile, per http://ygamretuta.me/2011/10/02/setting-up-active-admin-on-heroku-with-rails-3-1-and-cedar/
Part 7. FIXING RAILS SCAFFOLDING. After installing ActiveAdmin, the ‘rails g scaffold’ command no longer works normally. ActiveAdmin adds the inherit_resources gem, which has the side effect of replacing the normal “rails generate scaffold” process to one which by default is based upon inherit_resources. If you want to run the ‘normal’ rails g scaffold command you need to add -c=scaffold_controller
at the end of the command line, for example
rails g scaffold Foo name:string -c=scaffold_controller