Bort - A Base Rails Application

September 9th, 2008

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

Recommend Me

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.

You can follow any responses to this entry through the RSS 2.0 feed. Trackback from your own site.

50 Responses to “Bort - A Base Rails Application”

  1. September 9th, 2008 at 4:16 pm - Nate Says:

    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? ;)


  2. September 9th, 2008 at 4:20 pm - Jim Neath Says:

    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.


  3. September 9th, 2008 at 4:40 pm - Neon Says:

    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!) ;)


  4. September 9th, 2008 at 4:48 pm - Bence Nagy Says:

    RoleRequirement (http://code.google.com/p/rolerequirement/) is another interesting piece of rails plugins. And works like Restful Authentication.


  5. September 9th, 2008 at 5:21 pm - Adam Says:

    I tried to do this once. I failed. I’m glad to see you succeeded, thanks!


  6. September 9th, 2008 at 6:15 pm - Martin Says:

    How easy would it be to remove rspec and rspec rails to use shoulda instead


  7. September 9th, 2008 at 6:25 pm - Matt Hussein Platte Says:

    This should be in Rails core.


  8. September 9th, 2008 at 6:28 pm - Oleg Says:

    What the point of using AssetPackager is you can do something like this: javascript_include_tag :all, :cache => true Same applies to css.


  9. September 9th, 2008 at 7:09 pm - Soleone Says:

    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!


  10. September 9th, 2008 at 7:32 pm - Matt Says:

    @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.


  11. September 9th, 2008 at 7:48 pm - Daryl Says:

    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.


  12. September 9th, 2008 at 7:52 pm - Jim Neath Says:

    @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.


  13. September 9th, 2008 at 8:11 pm - Matt Says:

    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/


  14. September 9th, 2008 at 8:19 pm - Jim Neath Says:

    @Matt - Added a link to your fork, yeah?


  15. September 9th, 2008 at 8:37 pm - Oleg Says:

    @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.


  16. September 9th, 2008 at 8:49 pm - Phil @ Fudge Says:

    We’ve got 38 watchers for Bort on github. I wish I was that popular at school!


  17. September 9th, 2008 at 9:31 pm - Fred Says:

    I’m not seeing the setting.yml file.


  18. September 9th, 2008 at 10:23 pm - Adam Says:

    Thanks, it’s a good resource to have. I’ve been baseing my projects off of Goldberg up till now.


  19. September 9th, 2008 at 10:54 pm - vBharat.com » Bort - A Base Rails Application Says:

    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!…


  20. September 10th, 2008 at 5:07 am - Ashley Williams Says:

    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!


  21. September 10th, 2008 at 8:45 am - Bryce Says:

    Why not make it a generator like the rails command?


  22. September 10th, 2008 at 8:51 am - Matt Says:

    @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.


  23. September 10th, 2008 at 3:50 pm - Brandon Says:

    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!


  24. September 11th, 2008 at 1:03 pm - Nick Says:

    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!


  25. September 11th, 2008 at 1:15 pm - Jim Neath Says:

    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.


  26. September 11th, 2008 at 4:01 pm - grosser Says:

    exception notifier out, hoptoadapp.com in
    asset packer out, bundle fu in

    apart from that i agree :)


  27. September 12th, 2008 at 9:50 am - Tim Haines Says:

    Nice! Great to see you take the time to do this. What about paperclip, swfupload, rvideo, and ffmpeg? ;-)

    Tim.


  28. September 12th, 2008 at 7:44 pm - Ben Kerney Says:

    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!


  29. September 12th, 2008 at 7:44 pm - Ben Kerney Says:

    That should be “fixtures,” not “features”


  30. September 13th, 2008 at 9:25 am - Jim Neath Says:

    @Ben - will include it in the next release which should be sorted y the start of next week :)


  31. September 13th, 2008 at 10:54 pm - srb Says:

    How about tests?


  32. September 15th, 2008 at 3:54 pm - srb Says:

    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…


  33. September 16th, 2008 at 10:52 am - Bence Nagy Says:

    Thanks for RoleRequirement! ;)


  34. September 17th, 2008 at 9:49 pm - tanel Says:

    What about log rotating?


  35. September 23rd, 2008 at 3:14 pm - Kevin Says:

    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.


  36. October 1st, 2008 at 9:51 pm - Bill Gathen Says:

    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!


  37. October 3rd, 2008 at 3:30 pm - Bill Gathen Says:

    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!


  38. October 10th, 2008 at 7:41 am - mario Says:

    thank you! a huge timesaver.


  39. October 17th, 2008 at 7:49 am - saurabh purnaye Says:

    This application is Great! :)
    Thanks for the stuff and guidelines…


  40. October 21st, 2008 at 12:50 pm - Philip Rhoades Says:

    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.


  41. October 22nd, 2008 at 5:16 pm - Sean Says:

    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!


  42. October 24th, 2008 at 1:48 pm - srb Says:

    Phillip,

    Why are you copying this line?
    skip_before_filter :verify_authenticity_token, :only => :create

    You probably want this instead:
    before_filter :login_required


  43. November 1st, 2008 at 2:09 am - Philip Rhoades Says:

    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.


  44. November 1st, 2008 at 2:31 am - Philip Rhoades Says:

    Don’t worry - I worked this out . .

    Thanks,

    Phil.


  45. November 6th, 2008 at 5:37 pm - Douglas Says:

    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.


  46. November 8th, 2008 at 6:32 am - Adam Salter Says:

    I’m getting the same error as Douglas above. OSX 10.5, Rails 2.2


  47. November 8th, 2008 at 6:45 am - Adam Salter Says:

    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’)


  48. November 8th, 2008 at 10:05 am - Jim Neath Says:

    Thanks Adam, I’ll get that fix committed. :)


  49. December 2nd, 2008 at 2:45 am - Bob Calco Says:

    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


  50. December 2nd, 2008 at 3:06 am - Bob Calco Says:

    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


Leave a Reply

Jim Neath is a 24 year old Ruby on Rails developer from Manchester, UK. Contact Jim Neath

Recommend Me

Categories

Stalk Me