Fat Free CRM on Heroku

by Jim Gay

Heroku is an excellent way to easily deploy Rails applications. But there’s a trick to doing it: it’s a read-only file system.

To some, this may be old news, but to others who have come across a project using SASS, you might feel like your out of luck. Fat Free CRM, for example is a great new project, and it uses SASS. Try running it on Heroku and you’ll start getting frustrated. If you’re not familiar with SASS, it automatically generates static CSS files for you in production, meaning it needs write access to the file system.

So, what do you do? The good thing is Heroku has a plugin to help with SASS. But, in this instance, it doesn’t seem to work. I’ve installed it with Fat Free CRM and have pushed up to Heroku, but I get errors so rather than debug the issue you can try another option: http://github.com/mooktakim/heroku_sass_and_cache/tree/master.

Here’s a step-by-step. First, if you don’t have a Heroku account, signup and install the gem:

$ gem install heroku

Next, get the Fat Free CRM code:

$ git clone git://github.com/michaeldv/fat_free_crm.git

And turn it into a Heroku project

$ cd fat_free_crm
$ heroku create

You’ll need to install a plugin to manage the location for SASS files.

$ script/plugin install git://github.com/mooktakim/heroku_sass_and_cache.git

Read the documentation for the plugin, but you’ll need to add this to config/routes.rb:

map.heroku_sass_and_cache

Just drop that on the first line of your routes.rb file and commit all of your changes.

$ git add .
$ git commit -m "feeling sassy"
$ git push heroku master

That last bit will deploy your application to Heroku. Fat Free CRM requires that you run the rake crm:setup task.

$ heroku rake crm:setup USERNAME=myusername PASSWORD=mypass EMAIL=my@email.com

After that, you should have a working Fat Free CRM on Heroku. Try heroku open and you’ll land at your new login screen.

This will get you going, but you’ll find that minor things like storing avatars won’t work because they expect to be stored on the file system. Missing avatars aren’t an application deal-breaker and I imagine that there might be some options in the future for separate storage options, or even just using Gravatar.

If you have any luck with the official Sass support on Heroku, leave a comment and I’ll update the post.

Comments

Nick Merwin said on Thursday, October 15, 2009:

Hi, thanks for the write up – I just got this up and running on Heroku with a couple of additional steps.

  1. delete vendor/plugins/authlogic
  2. create a .gems file and add "authlogic"

Without these, you'll receive a nasty 500 error when trying to log in.

Cheers!

Kirk said on Friday, October 16, 2009:

Hey great post Jim. At this point, you're the foremost expert on heroku and fat-free! I think that within the last month, something might be broken with with fat-free on heroku. I installed everything OK, get the login page, and if I enter the CORRECT USERNAME and password, I get a CRASH:

NoMethodError (undefined method `valid_password?' for #):

app/models/authentication.rb:36:in `send' app/models/authentication.rb:36:in `validate_by_password' app/controllers/authentications_controller.rb:32:in `create' vendor/plugins/haml/rails/./lib/sass/plugin/rails.rb:19:in `process'

Would you mind trying to see if your fat-free installs by following your own instructions with a fresh installation? Thanks!

Jim Gay said on Tuesday, October 27, 2009:

The valid_password? error (strangely) came from a SASS deprecation.

This commit should fix it http://github.com/michaeldv/fat_free_crm/commit/e9babd9544ae473847adcad8aad140d0ba154fe1

So if you pull the latest, it should work fine for you.

Dan Melton said on Thursday, October 29, 2009:

This was great. Thanks for the article. I had some issues on heroku rake crm:setup. Essentially, it requires u to type in 'yes', which, then yielded a thousand plus y's on my screen. Totally weird and annoying. Anyway, I just ran the heroku rake crm:setup:settings and then the crm:setup:admin with USERNAME='user' PASSWORD='pass' EMAIL='email'

Jim Mulholland said on Wednesday, January 20, 2010:

Excellent post.

I too had to delete the AuthLogic plugin and add it as a Gem in the .gems file for Heroku.

However, AuthLogic version 2.1.3 (the latest as of today) caused a crazy "underscore" error. Downgrading the Gem to version 2.1.1 fixed the issue.

So, in summary, I did:

  • Deleted authlogic plugin
  • Added "config.gem 'authlogic'" to environment.rb
  • Created a .gems file with this line "authlogic —version 2.1.1"

Jd said on Saturday, January 01, 2011:

Just a note guys, at time of writing, the non-forked FFCRM can be deployed to Heroku with no modifications (I believe the SAAS plugin is included in the code).

To avoid the NoMethod error that people are getting after the first login, just make sure you run:
$ heroku restart
after you run the crm setup line. i.e:
$ git clone git://github.com/michaeldv/fat_free_crm.git
$ cd fat_free_crm
$ heroku create
$ heroku rake crm:setup USERNAME=myusername PASSWORD=mypass EMAIL=my@email.com
$ heroku restart

Hope that helps.

Post a comment


(required, but not displayed)

(optional)



(required)

1999 - 2012 © Saturn Flyer LLC 2127 S. Oxford St. Arlington, VA 22204

Call Jim Gay at 571 403 0338