I have been teaching myself Rails now and listening to many of Ryan Bates’ most excellent Rails Casts, about which I cannot say enough good things.
I figured there’s usually a small list of things that most web apps tend to need, and if you’re a beginner Rails programmer like myself, you have probably spent some time trying to learn how to put all this code in. In fact, if you have RailsCast religion like I do, you have been probably copy pasting it from Ryan’s tutorials, except now you need to build a new app that does some other cool thing and you can’t remember all the Devise, CanCan, DoorKeeper, OAuth magic you painstakingly put together the first time around.
And even if you know these gems inside-out like the logo of your favorite brand of yogurt, and can paste in their configurations with both hands cuffed, wouldn’t it be nice to have a simpler way to do it?
Well, now you do! Head on over to this Github repo and quickly get Devise, CanCan and OmniAuth (with two providers – Facebook and Twitter!) running in your app.*
There’s a README that will explain what you get. You have to run a setup file that will generate a script – you can generate a script that’s designed to run in either a UNIX shell, or at a Windows shell prompt (different directory separators, using copy instead of cp, etc.)
The script will do a variety of things – patch your Gemfile and your routes file, run a few configuration changes, patch around your app’s MVC code, migrate a few things into the database, and voila, you are set! Because I’m a fan of deploying apps to Heroku, my script will also use Postgres for your production database so you are Heroku-ready.
Some next steps I have planned:
- Add Doorkeeper support as well.
- Make this work on Rails 4!
- Add some basic tests.
- Add examples of common Rails patterns, like building drop down forms out of associations.
Have fun and comment on this post or file an issue if you find that something doesn’t work.
* Well, in your Rails3 app – Rails4 is on its way. And I haven’t completed testing in a *nix environment, only on Windows so far.