We start new Rails projects all the time, for client, side and internal projects. Each time we do the dance to get things just the way we like them. You probably have a similar process: switch the view library, set the database, use rspec, tweak this and that, etc. Even when you do it all the time, it still takes a little while to get to the point where you’re cranking on features.
We want to hit the ground running when starting a new project, so we created Raygun, an opinionated app generator. There are others out there, two that come to mind are Appscrolls and Suspenders. Folks have been talking about the “prime” stack (see Primo) too. We want something that captures how we do things at Carbon Five (at least on most of our projects).
What does the stack look like?
Raygun generates a new app with these libraries, all configured and ready to use:
Tweaks, Recipes, and Best Practices
Raygun also bakes in a handful of configuration tweaks that we think are useful for most projects. Here’s a sample:
- User model with sign in, sign up, password recovery and administration (see auth* below)
- Ready for deploying to Heroku
- Transactional acceptance specs
rake db:sample_datato load a small set of data for development
- Pull the secret token from the environment
- Threadsafe enabled by default (as will be the case with Rails 4)
- Enable basic auth by setting an environment variable
- Use mailcatcher if it’s listening
- Bootstrap compatible layout and custom view generator templates
- Custom spec generator templates that use factory girl when appropriate
Code generated by default is usually far enough from what I want that I don’t use generators. Raygun includes custom generator templates so that scaffold (view, controllers, and specs) includes what you would expect for use with Slim, Sorcery, Cancan, Bootstrap, Rspec, and Factory Girl. It’s not perfect, but it’s more useful than what you would get otherwise.
The templates are right in the project’s lib directory, so you can tweak them for your project and its evolution.
Raygun also includes a simple user scaffold with authentication views/controllers based on Sorcery. These may be useful and also serves as examples of how to use Cancan for authorization. Not every app needs auth and a future version of Raygun will have a flag for leaving it out.
gem install raygun. Be sure to check the requirements before doing anything with your freshly generated app. Otherwise you may experience a misfire. Then, fire away…
Then explore the code to see what’s included.
I created Raygun not only to have something that might be useful, but also so that it could focus discussion about the Carbon Five Stack within our organization. We don’t all share the same preferences and that’s okay. Raygun is going to evolve as our preferences and options change. In the near term, I hope to roll out Rails 4 support and add a flag for leaving out the auth bits. Submit a pull request if there’s something you think should be part of it.
We’ve used it on a couple of projects and want to let others know about it. Be kind, this is Raygun’s first exposure to the outside world. Something will probably break. Let us know and we’ll fix it up real quick. Enjoy!
- v0.0.22 includes a fix for ubuntu users