Jim Neath

Manchester based Ruby on Rails & Facebook App Developer

Showing blog posts tagged as "Bort"

Speeding Up Rails Development

Over the last few months I’ve realised that the speed at which I develop new projects is a lot quicker than it used to be. So I thought I’d share some of the things I’ve learned and also some quite obvious things (to me at least).

Use a Base Application

I’m obviously going to be horrifically biased due to the fact that I helped to develop Bort, but I think that base apps are the way to roll. They save you about half a days worth of development and let you get straight into developing your application rather than fucking around doing the same monotonous stuff every time.

So here’s a run down of base apps floating around:

I haven’t used any of these apart from Bort, so I can’t really give you any opinion but everything I’ve seen by Thoughtbot and James Golick have always been awesome. Just look through them and find which one suits your needs.

I would like to end this section with a nice graph taken from Rails Rumble Observations, part II :)

Write Your Own Scaffold Generator

The default Rails scaffold generator is alright for prototyping an app but let’s face it, you wouldn’t use it for everything. So why don’t you made your own that you can use for everything. At the start of the last project we worked on, we spent 2-3 days working on a scaffold generator that would help to generate parts of the admin.

We made the generator generate all the search stuff, add sortable tables, generate basic specs and a whole bunch of other awesome stuff. Now we can get an awesome admin section set up for a model by running line from terminal.

This must have saved us at least a weeks worth of time. Time that we can now spend making sure that the rest of the site is as brilliant as possible. With the extra time, you take it easy, or you could add extra features, improve the UI, whatever. Keep it RESTful, kids.

Use a Form Builder

I hate forms. No secret there. But alas, nearly every application you’ll develop need to have forms. I wrote a custom form builder for the chaps at Fudge and it saves us a hell of a lot of time.

Now instead of writing something like the following:

<% form_for @story do |f| %>
  <%= f.error_messages %>
  <fieldset>
    <legend>Story Details</legend>
    <ol>
      <li>
        <%= f.label :title %>
        <%= f.text_field :title %>
      </li>
      <li>
        <%= f.label :body, 'Content' %>
        <%= f.text_area :body %>
      </li>
    </ol>
    <div class="buttons">
      <%= f.submit 'Create' %>
    </div>
  </fieldset>
<% end %>

Using our form builder we write:

<% form_for @story do |f| %>
  <%= f.error_messages %>
  <% f.field_set "Story Details" do %>
    <%= f.text_field :title %>
    <%= f.text_area :body, :label => 'Content' %>
  <% end %>
  <%= f.submit 'Create' %>
<% end %>

Now imagine you’re got to write close to 50 forms for an application. Can you guess which ones saves you time? Which one is more enjoyable to use? You got it.

Now while I wouldn’t say our form builder is ready for the general coding public (it isn’t), there are still a few out there.

I have used Semantic Form Builder by RubyPond before and it also happens to be the one we based out form builder on.

Build a Populate Rake Task

We started using Populator/Faker a couple of months a go and this is probably one of our biggest time savers. It’s a pain in the ass adding test data into your applications.

Ryan Bates has made a great railscast on how to use Populator along with Faker to generate fake datausing a rake task so I’ll leave it to his awesome video to tell you all about it.

There are also a couple other options out there for generating fake data, the random-data gem and the Forgery plugin.

Peter Cooper has a more thorough run down of all three options over at Rails Inside.

Use Plugins/Gems

This should really go without saying, but I’ve seen a few people trying to write (poor) code for tasks that have already been solved, tested and improved on.

Gems and plugins are probably your biggest time saver. One of the things I love about the ruby community is that a lot of people give back to it.

If you have a problem, have a look on the awesome GitHub and see if there’s a plugin/gem floating around that looks like it could solve your problem. Try it out. If it works brilliant, if not see if you can fix it and improve the original code. Then if someone else has the same problem, they can use the plugin. If everyone helps out, we all have an easier job, we can do less work and enjoy life more.

Seriously, Just Buy a Fucking Mac

Just do it. Stop making excuses. I was a Windows user for about ten years but mainly because I didn’t know any better. I now work full time on a mac, both at home and at work, and there’s not a thing you could do to make me go back to Windows.

Windows simply won’t do a lot of things that you’ll want to do. Background jobs? Not a chance. Git? oh yeah, you can use msysgit but who the fuck wants to open up a separate program just to use git? Fuck off Windows. You’re slow and you suck.

Why get a mac? Rails runs faster. You can use the best text editor around, TextMate. You can install all those gems and plugins that all say: “This won’t work on Windows”.

Think getting a mac is too expensive? Get a low spec mac mini for $599. That’s what I started using and even though it’s low spec I never had a problem with it. You can use your USB keyboard, mouse and your monitor from your Windows machine. Still think it’s too much? Have a look on Amazon…

So do you, my lovely readers, have any more suggestions/tips to speed up your development?

Bort Update to Rails 2.2

I probably should have done this sooner but I’ve finally got around to updating Bort to Rails 2.2

Here are some other changed.

Will_paginate, AASM, Rspec and Rspec-rails updated to gems

I’ve decided to remove the above plugins and unpack the most recent version into the vendor/gems directory. The main reason is its easier to keep track of which version you’re using and what needs updating. So Bort is currently rocking the most recent versions of those gems.

Exception Notifier Email Automatically Set to the Email Set in Settings.yml

This is something I thought we’d already done but alas not. Thanks to feedback on UserVoice for that one.

README Updated

The readme has been updated to let people know that they need to change the default admin password in the bort_migration along with the RESTFUL_AUTH_SITE_KEY in each of the environment files.

If you haven’t done this yet, make sure you do it yo.

Multistage Capistrano Deployment

Thanks for Phil Jeffs for fixing this one. Bort is now setup out of the box to deploy to a staging environment along with production.

Bort Sends a 404 on ActiveRecord::RecordNotFound

This is something that I normally forget to do in applications so it’s now baked into Bort. If a user requests a page and the record it’s looking for doesn’t exist, they’ll get sent to the 404 page with the correct status. If you don’t want this to happen, just remove the code from application.rb file.

Rake db:database_dump

Matt Hall has added a rake task to allow you to dump the contents of you database. Simply run rake db:database to get a dump of all the contents of your database.

Upcoming Suggested Changes

The two main upcoming changes to Bort are:

Default User Admin Panel

A lot of people seem to want this feature. We’re currently on the fence about it. Bort has tried to keep as simple as possible while keeping the features that a lot of us use. Thoughts on this would be great.

Add i18n support

Again a lot of people seem to want this but again we’re on the fence due to the reason above.

Removal of Role_requirement

I’ve noticed a lot of people on github who fork Bort seem to remove role_requirement. Also, I’ve found myself doing the same thing in favour of other options.

What do you guys think?

Suggestions? Problems?

As always, if you have any suggestions or problems then leave a message on our UserVoice and we’ll see what we can do.

Tagged with

Bort! Now with OpenID!

Just a small update on Bort.

Bort Project Page

I decided to make a dedicated page for Bort, so I only have one place to keep up to date.

Bort Project Page

Open ID Authentication

I’ve integrated OpenID with RESTful Auth on Bort in the new version. I’ll be perfectly honest though, I’ve never actually set up OpenID before, so I’d appreciate if people could take a look at it and let me know if it sucks.

User Voice! Load Noises!

We’ve set up an account on User Voice so you guys can submit ideas and all that jazz to us, then we can act like power hungry sultans and deny your ideas.

Bort @ User Voice

At this moment in time, we have 239 watchers on Github and are the 25th most popular project. Hooray for us.

Tagged with

Bort - A Base Rails Application

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.

Tagged with

I am available for freelance work! Click here to email me.

Jim Neath is a Freelance Ruby on Rails & Facebook app developer from Manchester, UK, currently working for Engine Yard.