A Fresh Cup is Mike Gunderloy's software development weblog, covering Ruby on Rails and whatever else I find interesting in the universe of software. I'm a full-time Rails developer and contributor, available for long- or short-term consulting, with solid experience in working as part of a distributed team. If you'd like to hire me, drop me a line. I'm also the author of Rails Rescue Handbook and Rails Freelancing Handbook.

Navigation
« Double Shot #494 | Main | Double Shot #493 »
Sunday
Jul122009

Big Old Rails Template

A few people have asked me about the Rails application template that I've put together recently. For those who are interested, it's now available for review and download as a gist. To use it, just specify the -m switch when creating a Rails application:

[sourcecode language='ruby']
rails new_app_name -m lark_template.rb
[/sourcecode]

I should warn you of two things. First, it's a pretty heavyweight template, sticking a lot of stuff into the new application. This suits me, because I have a lot of things I use in just about every application, but it may not suit you. Second, Rails templates are not one-size-fits-all; you'd be better off treating this as a starting point to steal from than a finished template to use (though if you want to use it, feel free).

Here's a list of what this template sets up:

Coding Tools
  • Authlogic for user authentication, including password resets, anonymous_only, authenticated_only, admin_only application helpers

  • World's simplest authorization system: manage multiple string roles on users with User#add_role, User#remove_role, User#clear_roles, and User#has_role?

  • Date formats: :us, :us_with_time, :short_day, :long_day

  • live-validations for client-side JavaScript data entry validation. Add :live_validations => true to form_for declarations to hook this up.

  • Paperclip for attachment management

  • /pages/css_test will show most CSS styles in action

  • Searchlogic for magic named scopes and search forms - http://rdoc.info/projects/binarylogic/searchlogic. Includes attribute_equals, attribute_does_not_equal, attribute_begins_with, attribute_like, attribute_ends_with, attribute_greater_than, attribute_null, attribute_blank etc. etc.

  • Stringex for extra string functionality - acts_as_url, String#to_ascii, String#to_html, String#to_url, String#remove_formatting, String.random

  • US State application helpers

  • will-paginate for pagination


Database Tools
  • Hooked up for PostgreSQL

  • admin-data plugin for administrative UI. http://localhost:3000/admin_data will get you to the application's data. On production, only admin can view data, no one can edit (modify config/initializers/admin_data.rb to adjust this)

  • db-populate for seed data


Deployment Tools
  • fast_remote_cache strategy for deployment

  • rubiadhstrano for deployment recipes; automatically uses multiple targets, so: cap production deploy for deployment to production

  • superdeploy for additional Capistrano tasks. cap -T for full list.

External Services
  • Exceptional for error tracking. Go to /pages/kaboom to test after finishing Exceptional setup.

  • New Relic for performance tracking

Testing Tools
  • Shoulda and Test::Unit for testing

  • Mocha for mocking

  • Object Daddy for factories

  • Generated code is already covered by tests

  • parallel-test for faster testing. rake test:parallel:prepare[2] to set up two test databases. rake test:parallel[2] to distribute tests across two cores

  • rack-bug for request/response/perf analysis. http://localhost:3000/__rack_bug__/bookmarklet.html to add bookmarklet to browser.

  • shmacros for additional Shoulda macros: should_accept_nested_attributes_for, should_act_as_taggable_on, should_callback, should_delegate, more

  • More extra shoulda macros: should_have_before_filter, should_have_after_filter

  • metric-fu for static code analysis. rake metrics:all, configure in Rakefile

  • inaction-mailer is installed for development environment, so mails sent during dev will end up as files in /tmp/sent_mails

Reader Comments (5)

Hey Mike,

Nice recipe. You weren't kidding about the size :-)

For those interested in this recipe, but would like to customize it a bit further, take a look at beet: http://jackdempsey.github.com/beet I believe you linked to it the other day. It has some recipes built in, like authlogic, but could certainly benefit from some of these as well.

July 12, 2009 | Unregistered CommenterJack Dempsey

Thanks mike! I have been playing with some of the other metaframeworks out there, but I like your approach.

July 14, 2009 | Unregistered CommenterGreg

Mike,
I'll bite, what the heck is "rubiadhstrano". Google comes up with virtually nothing.

July 16, 2009 | Unregistered CommenterKarl

I must be a total moron for *just* realizing that BigOldRailsTemplate = BORT!

October 25, 2009 | Unregistered CommenterMark Richman

PostPost a New Comment

Enter your information below to add a new comment.
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>