An Introduction
When I set up a new rails app, I generally do the same things every time. Set up a config file, install RESTful authentication, add password recovery stuff, blah blah. I’m sick of doing the same stuff over and over again. Enter Bort.
Bort is a base application featuring all the things I set up with every application. Now I can just download the app from git and be up and running within a matter of minutes. POW!
For those of you wondering is Bort stands for anything like “Bionic Optical Radioactive Trout”, it doesn’t. It’s taken from this episode of The Simpsons:
Anyway, enough of this piffle, on to the features:
The Features
I’m going to copy and paste this jazz from the readme file because, quite frankly, I’m lazy.
RESTful Authentication
RESTful Authentication is already setup. The routes are setup, along with the mailers and observers. Forgotten password comes setup, so you don’t have to mess around setting it up with every project.
The AASM plugin comes pre-installed. RESTful Authentication is also setup to use user activation.
Will Paginate
We use will_paginate in pretty much every project we use, so Bort comes with it pre-installed.
Rspec & Rspec-rails
You should be testing your code, so Bort comes with Rspec and Rspec-rails already installed so you’re ready to roll.
Exception Notifier
You don’t want your applications to crash and burn so Exception Notifier is already installed to let you know when everything goes to shit.
Asset Packager
Packages up your css/javascript so you’re not sending 143 files down to the user at the same time. Reduces load times and saves you bandwidth.
Routes
The routes for RESful Auth and the forgot password stuff are already sorted for you.
Settings YAML
There is a settings.yml file that contains site-wide stuff. The site name, url and admin email are all used in the RESTful Auth mailers, so you don’t need to worry about editing them.
Database YAML
The database.yml defaults to sqlite3 but also contains the settings for MySQL in comments so you can switch over easily.
Capistrano Recipe
Bort comes ready to rock capistrano. The recipe that is setup is based on using git and passenger. Edit as you see fit.
Uses the Database for Sessions
Bort is setup to use the database to store sessions by default.
Misc
- password and password_confirmation are set up to be filtered
- there is a default application layout file
- a page title helper has been added
- index.html is already deleted
- rails.png is already deleted
- a few changes have been made to the default views
Using Bort
The git repo is located here: http://github.com/fudgestudios/bort/tree/master
- Download and unzip Bort
- Edit the database.yml and the settings.yml files
- Rake db:migrate
- Have a brew and celebrate
Suggestions etc
If you have any suggestions about things we should add, edit, delete from Bort then let me know. Think we should gemify it? You decide.
(Possibly) Related Posts
If you found this post or anything else on this site of any use, then please take the time to recommend me on Working with Rails.

50 Responses to “Bort - A Base Rails Application”
How about changing the description of Bort to something that can be found through searching on github? “Chester says Bort, yeah?” wasn’t the first thing I thought to search on, you know? ;)
Haha that’s some legacy stuff from internal work.
I’m going to update the github page tonight/tomorrow as some stuff has changed since it was set up.
Wow, what a great idea, I will give this a try and see if I can make it work! (All of 2 weeks RoR experience so far!) ;)
RoleRequirement (http://code.google.com/p/rolerequirement/) is another interesting piece of rails plugins. And works like Restful Authentication.
I tried to do this once. I failed. I’m glad to see you succeeded, thanks!
How easy would it be to remove rspec and rspec rails to use shoulda instead
This should be in Rails core.
What the point of using AssetPackager is you can do something like this: javascript_include_tag :all, :cache => true Same applies to css.
That’s awesome. Totally fitting my lazy copy and paste work style for new projects, hehe! And I like the name too. Will definitely start my next app with this. Thanks mayn!
@Oleg: Asset packager removes whitespace and comments from your files, reducing the total file size. The javascript_include_tag method keeps all whitespace and comments, which makes for better readability, but as we’re using Bort on high-traffic sites, we need to be concious of the size of files being sent over the wire.
I’d also suggest open__id_authentication as well. I end up integrating this all the time now.
Very cool idea just cloning now and will check it out.
@Oleg - See Matt’s comments.
@Daryl - OpenID stuff is one of the thing’s I’ve been thinking of adding to the mix. I’ll look into tomorrow.
There is also a version of bort with email / password authentication instead of the traditional username / password combo - just for those of us that prefer using email addresses instead of usernames. More details here:
http://matthall.wordpress.com/2008/09/09/a-bort-fork-rails-base-application/
@Matt - Added a link to your fork, yeah?
@Matt - Does whitespace and comments really make such a big difference to warrant use of AssetPackager, especially when you should be sending content gzipped anyway? AssetPackager made sense pre Rails 2.0, now I just don’t see the point.
We’ve got 38 watchers for Bort on github. I wish I was that popular at school!
I’m not seeing the setting.yml file.
Thanks, it’s a good resource to have. I’ve been baseing my projects off of Goldberg up till now.
From vBharat.com » Bort - A Base Rails Application…
Bort is a base application featuring all the things I set up with every application. Now I can just download the app from git and be up and running within a matter of minutes. POW!…
If you were this popular at school, maybe Bort wouldn’t exist!
Very cool, going to use Bort for my next project! (I hope you keep it updated with the latest stable Rails!)
Thanks!
Why not make it a generator like the rails command?
@Oleg: Using AssetPackager isn’t a requirement for Bort - if you feel happy using the packager in rails, then fair enough - it’ll still work.
@Jim: Ta for the link.
Great idea! I loved that episode!
…
Guy on PA: Attention Marge Simpson! Your son has been arrested!
Woman in store: Oh I’d hate to be that boy’s mother.
Guy on PA: Attention Marge Simpson! We’ve also arrested your older, balder, fatter son!
…
Marge: I wish there was a hole I could crawl into and die.
German Guards: OK! Throw her in de hole!
I just downloaded this bundle and got it running in no time. I do have 2 questions:
like @Fred mentioned above, I don’t see the settings.yml file, I do see in the config directory a config.yml. A second question is where do I put the config settings for my outgoing mail server? I want to send mails via my company’s smtp server?
Thanks!
The settings is actually the config.yml file. I should probably edit this post to reflect that.
For the email settings, I’ll add that some time this week.
exception notifier out, hoptoadapp.com in
asset packer out, bundle fu in
apart from that i agree :)
Nice! Great to see you take the time to do this. What about paperclip, swfupload, rvideo, and ffmpeg? ;-)
Tim.
Jim this is awesome. The only change I’ve made so far is to move the REST_AUTH_SITE_KEY from config/initializers/site_keys.rb to config/environments/*.rb so that I can make my own key for development and production without breaking the included features. Thanks a bunch!
That should be “fixtures,” not “features”
@Ben - will include it in the next release which should be sorted y the start of next week :)
How about tests?
Doh!
There are plenty of Rspec tests.
The only thing I would change in it as a default base app is to change the landing page after signup/login to something else and just make it a replace me page with instructions on changing the route.
I think the real value add once the all the setup is up is to document everything - particularly where to go after successful setup - ie- how to add your models, where to put the restful security, how to use the various installed plugins, etc…
Thanks for RoleRequirement! ;)
What about log rotating?
Hi,
I notice the default routes have been removed from routes.rb.
It seems that not having them breaks the reset password stuff here:
{ :action => ‘update_after_forgetting’ } do |f| %>
We get a missing route error.
Worked fine in Mongrel, but when I tried it under Passenger I kept getting the server root url after logging in/out.
Changing all occurrences of “redirect_back_or_default(’/')” to “redirect_back_or_default(root_url)” got me going again. There are 2 in sessions_controller.rb and 3 in users_controller.rb.
Otherwise, great setup. Thanks!
Ran into this exception_notifier problem: http://groups.google.com/group/rubyonrails-core/browse_thread/thread/eaf210a7d099ad57?pli=1
Applied this patch manually: http://github.com/rails/exception_notification/commit/019b0de35a328c78204adc0fe93e942f011e0002
…and we’re rolling again!
thank you! a huge timesaver.
This application is Great! :)
Thanks for the stuff and guidelines…
I have bort working in isolation but when I create a new table “dummy” with:
script/generate scaffold Dummy status:string lastname:string firstname:string email:string phone:string description:text
run:
rake db:migrate
and then copy the line:
skip_before_filter :verify_authenticity_token, :only => :create
from the sessions_controller.rb file to the dummies_controller.rb file and then viewing:
http://localhost:3000/dummies
does not display the login page . . what am I not doing/doing wrong?
Thanks,
Phil.
Bort is really handy, but I feel that with the introduction of open ID support you may have gone a little too far in one direction. None of my projects ever use open id, for a variety of reasons. Hopefully you won’t get caught up in adding too many more features at the base, as the last thing a cool time-saving project like this needs is feature bloat. Either way, thanks for making this!
Phillip,
Why are you copying this line?
skip_before_filter :verify_authenticity_token, :only => :create
You probably want this instead:
before_filter :login_required
srb,
Thanks - I did work that out eventually . .
Next question relating to authentication - for a library app (books, CDs, DVDs) I want to use the Rails dir:
pricom.com.au/library
and I have started using Passenger (mod_rails) - I had to hard code “library” into paths in layout files so “authors”, “books” etc can be found (eg /library/books) because RailsBaseURI doesn’t seem to work past the base name. Anyway, activation emails are being sent out without the “library” eg with a URL of:
http://pricom.com.au/activate/b4cd0. . .
Where do I hard code “library” to fix the URL?
Thanks,
Phil.
Don’t worry - I worked this out . .
Thanks,
Phil.
When I run `rake db:migrate` I get the following error…
`rake aborted! no such file to load — spec/rake/spectask`. What gives? I am on Windows XP, Rails 2.2.
I’m getting the same error as Douglas above. OSX 10.5, Rails 2.2
I was able to fix the error `rake aborted! no such file to load — spec/rake/spectask` by changing line 7 of lib/tasks/rspec.task to:
rspec_base = File.expand_path(File.dirname(__FILE__) + ‘/../../vendor/gems/rspec-1.1.11/lib’)
Thanks Adam, I’ll get that fix committed. :)
I’m running into a problem during the migration when user.register! is called… deep in the bowels of aasm.rb, the call on line 118 to aasm_state_object_for_state(aasm_current_state) is returning nil, so rake db:migrate fails when it tries to call nil.call_action(:enter, self).
I took the creation of the admin role and initial admin user out of the migration (or rather, commented it out). After I successfully ran the migration without those steps, I manually reproduced them in the console.
I was able to create the admin role and the user, and add the admin role to the user. But calls to both user.register! and user.activate! yield the following error:
MethodError: You have a nil object when you didn’t expect it!
The error occurred while evaluating nil.call_action
from /vendor/gems/rubyist-aasm-2.0.2/lib/aasm.rb:118:in ‘aasm_fire_event’
from /vendor/gems/rubyist-aasm-2.0.2/lib/aasm.rb:56:in ‘register!’
from (irb):8
(substitute ‘register!’ with ‘activate!’ when I call user.activate! in above trace.)
I am running Rails 2.2.2, not 2.2.0.
- Bob
OK I figured out what my problem was. I’m using a non-standard database adapter on win32… Sam Smoot’s mssqlclient. I have been massaging it to work on Rails 2.2 with some success but I occasionally find some odd stuff going on. In this case, it’s prepending default strings with “N”. In SQL Server you usually write something like N’somestring’. Apparently it’s concatenating the N and the string. So for example, the ‘name’ attribute of user, which defaults to ”, is “N”. I can fix this. Changing the user.state to “passive” (instead of Npassive) and then calling user.register! an user.activate! did the trick.
- Bob