August 2009
35 posts
4 tags
Sharing is caring
We recently described our experimental Cucumber directory convention.
Here’s another directory convention I’ve been using. Mise en place.
What’s wrong with this...
Internbot Chronicles #5: The end
Today’s my last day here in the Boston office. At the end of the week I’m heading back to the great white north of New York. I’ve written enough about what I’ve hacked on during my time here, I’d rather wrap up with how others have made the past few months awesome.
The group
If you’ve got a local Ruby group in your area, go to it. The members of Boston.rb...
11 tags
Testing Paperclip on S3 with Cucumber & Factory...
We’ve been using Heroku as a staging environment for our latest project. One constraint is a read-only filesystem.
The most apparent effect of this is we cannot allow users to upload files to the filesystem.
Fine. Paperclip has an S3 storage option.
Testing
Webrat has a very nice existing convention for interacting with file fields:
When /^I attach the file at "([^\"]*)" to...
assert rand() > 0.5
Yeah so you might think it’d be nice to hire a Femfatalatron as your housekeeper, but do you know how the inner circuits work?? DO YOU!! Of course not; it’s a strong AI so it’s nondeterministic. One day, you will ask why there is a spot on your nice wine glasses. The next day, your house is in shambles. Firey, robot-incinerated shambles.
On the flip side, we have our...
The thoughtbot office was a-rumblin'
The Rails Rumble 2009 was just this weekend and the thoughtbot office was packed with competitors, including two non-thoughtbot teams! Here’s the breakdown:
Photo Bagel
A deliciously-named app written solo by Chap Ambrose, Photo Bagel hosts and tracks daily photo uploads. Getting started is as easy as emailing a photo to photobagel@gmail.com.
Who Would Win a Fight?
Ah the age-old...
1 tag
Render alternate layouts in IE6 with only CSS
With all the rage lately being around dropping IE6, I found myself wanting to show an alternate layout for just IE6 users. I thought some of you front end people might be interested in how I did it, using only CSS (and a simple conditional comment). I got the chance to try this technique for a personal project myself and a few other guys put together this weekend for Rails Rumble. Sadly this IE6...
Let's get ready to rummmmmmmble
Well it’s that time of year again - time for the rails rumble. The magical weekend of coffee filled nights and panic-filled days enjoyed by web developers and designers alike each and every fall since time immemorial.
The Man
Here at thoughtbot, we’re proud to have Mr Kevin Burg in our employ as a web designer. If you don’t know, Kevin’s sort of a big deal - having won...
1 tag
Robotic Dinosaur Museum Cave →
Back in June, I mentioned that we were looking to hire both designers and developers. Hiring is tough, but we take our time, and don’t compromise to find the right people. And it pays off.
I’ll be speaking in detail about hiring Rails developers in my talk Succeeding at Rails at Lone Star Ruby Conference next week in Austin, TX.
I’m pleased to introduce you to the new members...
6 tags
Introduction to using vim for Rails development
Someone recently asked us to do “vim on Rails” screencasts.
So, we’re responding with this experiment. Let us know if this is valuable and we’ll try to improve things like audio quality.
Install Joe Ferris’ config files
git clone git://github.com/jferris/config_files.git
cd config_files
./install.sh
Installing...
Startup panel review
Panelists
Last night’s startup panel included representatives from self-funded (thoughtbot), angel funded (oneforty), and Series A and Series B funded companies (Panjiva and Zendesk). All four companies are using Ruby in some form.
While many topics were addressed, such as why each company uses Rails, how they developed their products, how they hire, and how they secured funding, there...
Gemcutter.org redesign preview
We recently finished a design overhaul of Gemcutter.org and wanted to share a design preview of a few key screens.
Home page
Gemcutter.org is a fast and easy approach to ruby gem hosting so the design is intended to present useful information clearly. The homepage is kept fairly simple and utilizes a search field as the primary entry point to navigation.
Index Page
Gems are organized...
rebase like a boss
Everyone who loves Git hopefully loves branching. However, there’s a problem with branching: merging your work back in. Suprisingly enough, Git’s inflexibility makes this action quite simple. It’s my opinion that Git users should be branching frequently, and rebasing them back into the mainline when ready.
Merges should be used only to denote when long lived branches (read:...
Ruby web startup panel tonight
Tonight, TechStars is hosting a panel discussion on Ruby web startups. Panelists include senior representatives from:
thoughtbot
ZenDesk
Panjiva
oneforty
See Boston.rb for more information on the panelists.
The event will take place from 7pm-10pm at 727 Mass Ave, Central Square, Cambridge.
Broad focus
The night will generally focus on:
Tactical issues of running a startup on Rails
...
YARD sale clearance
We’ve previously stated our commitment to rdoc.info as the official documentation home of our open source projects.
Add the documentation for Clearance to that list.
Why
Blog posts and wikis are good for tutorials, not for API documentation.
YARD is awesome. Take five minutes to scan the Getting Started page.
rdoc.info is open source. I’m happy to outsource documentation...
Cucumber directory convention
I’ve been organizing Cucumber features in Rails apps using a strict directory convention:
features/admins/
features/api_clients/
features/users/
features/visitors/
The convention
All features go inside a directory named after a user type (including non-human users such as API clients).
Visitors are un-authenticated users.
Users are authenticated users.
Use domain-specific language....
5 tags
Blossom the lovely stars, the forget-me-nots of...
“Silently, one by one, in the infinite meadows of Heaven,
Blossom the lovely stars, the forget-me-nots of the angels.”
Evangeline by Henry Wadsworth Longfellow
You’re writing a Rails app. You want users to be able to sign in.
You decide to use Clearance.
How do you expect it to handle “remember me” out of the box?
Remember unchecked by default
...
A grand piano for your violin
Database indexes
What are database indexes? If you’re building web apps powered by a relational database, you should know.
A database index is a data structure in the database which improves the speed of operations (typically row lookups) on a database table, or across tables. Think of it like the index of a book. If you’re reading a book about the Wu Tang Clan and you want to...
5 tags
Boston.rb redesign
Boston.rb was recently re-designed. It went from this…
… to this:
I know, I know… you’re thinking: that must have cost a fortune! What’d you do, hire Sterling Cooper?
Nope. I’ll let you in on a little secret but I want you to hold on to your horses… it cost $0 to redesign.
That’s right. It was done using a new-fangled technique called...
3 tags
Already confirmed
If you’re using Clearance and Hoptoad, chances are you’ve seen this error:
You see, in the dead of the New England winter, we got academic about being HTTP fluent. In the process, we made our Rails apps less usable for one edge case:
Users click their confirmation email more than once.
Why (using email as a bookmark, double-clicking) doesn’t really matter. Hoptoad has shown...
5 tags
Why Do Rubyists Test So Completely?
The Ruby community, according to some data I am making up, has the strongest test-driven development attitude. Not all of us TATFT; not all of us test most of the time; and not all of us test ever—but those who do test make up a larger proportion than they do in, say, the Java world.
But why? What is it about Ruby that drives us to attain 100% code coverage?
Cultural Pressure
We test. Kent...
4 tags
stupid ruby tricks
Over the past few months of slinging Ruby here at Thoughtbot, I’ve picked up quite a few stupid ruby tricks smart ruby techniques that really help out your code. If you’ve got your own, feel free to leave a comment.
Destructuring yielded arrays
def touch_down yield [3, 7] puts "touchdown!" end touch_down do |(first_down, second_down)| puts "#{first_down} yards on the run" puts...
5 tags
Limerick Rake
Limerick Rake is a collection of useful rake tasks for Rails apps. Some we wrote ourselves, many we’ve collected from others in the community. We’re always on the lookout for helpful rake tasks so if you have anything, please post them in the comments. To use in a Rails app:
script/plugin install git://github.com/thoughtbot/limerick_rake.git
Database
Read tasks/database.rake for...
Rails in the Lone Star State
If you haven’t already heard, we’re going to be be both speaking and running a training session at the Lone Star Ruby Conference 2009, which runs from August 27-29 in Austin, TX.
Our training session is an enhanced version of our regular Ruby on Rails training session titled “Second Gear”, where we’ll be showing you how to increase the velocity of your Rails...
5 tags
Unpopular Developer 5: Stop Unit Testing Your...
This goes out to all the veteran Ruby on Rails developers: those who have the RESTful scaffold memorized down to their fingertips; those who can write the tests for it using Cucumber with Webrat, Rails integration tests with Webrat, Rails controller tests with RSpec, Test::Unit, or Shoulda, using mocking, stubbing, test spies, or old-school assertion style:
Stop unit testing the RESTful...
1 tag
Analysis paralysis: access control
Have you ever analyzed the “access control” (also called “authorization”) options in Rails and thought, “something better must be out there”?
I’ve analyzed libraries and concluded “authorization needs to be custom in each app.” Many will disagree.
If you’ve reached the same conclusion, however, your decisions are not over:
Do you test...
5 tags
High Voltage
Last year, we wrote about static pages for the enterprise.
Since then, we’ve fine-tuned our PagesController into a Rails engine called High Voltage.
Static pages?
Yeah, like “About us”, “Directions”, marketing pages, etc.
Installation
script/plugin install git://github.com/thoughtbot/high_voltage.git
Usage
Write your static pages and put them in the...
Rails in the Aloha State
I’m happy to announce that I’ll be speaking with Tammer Saleh at Aloha on Rails on Ruby on Rails best practices.
You’re Doing It Wrong – Chad Pytel and Tammer Saleh As experienced Rails consultants, and authors of the upcoming Rails Antipatterns book, Chad Pytel and Tammer Saleh have seen their fair share of terrible code. They’ll discuss some common AntiPatterns they’ve seen in the wild,...
6 tags
International clearance
In May, Timur Vafin, Marcel Goerner, and Eugene Bolshakov helped make Clearance i18n-aware.
Baxter, you know I don’t speak Spanish
Why should you care?
Even if your language is English, this means you can control all of Clearance’s flash keys and email subjects from one YAML file.
Pretty sweet! Thanks for the patches, fellas.
en:
clearance:
models:
clearance_mailer:
...
A suspension bridge got cut from the varsity squad
Since introducing you to suspenders almost a year ago, we’ve really enjoyed using it. When we have a good time, so do you. So does everyone.
When we work on projects for ourselves or clients, we constantly learn what decisions we can “make in advance” and avoid repeating on new projects.
Even if it’s only a matter of saving an hour here or there on set up, this adds up...
We're now tumbling
We’ve just moved this blog over to be powered by tumblr.
Importing all of the content from mephisto into tumblr and disqus wasn’t an easy feat, so thanks go out to Mike Burns, Nick Quaranto and the others who were involved in making it happen.
We apologize if some older posts show up as new again in your feed reader. Other than that, you shouldn’t notice anything dramatically...
Spy vs spy
Update: this functionality has been extracted to the bourne gem: 159805295
We’ve recently been making use of an alternative to the traditional mock-and-stub pattern common in Ruby: the Test Spy.
What do you mean, spy?
Test spies allow you to record method invocations for later verification. Basic usage goes something like this:
describe PostsController do
it "should show the...
6 tags
Fashion Runway: ERb vs. Haml
With Rails 3 around the corner, choosing a templating framework (and testing frameworks and ORMs) will be a decision Rails developers can make on even ground. ERb and Haml will be equally supported in places such as generators.
So how do we choose?
Looks
A lot of people think Haml is hot.
It’s true. Haml looks very clean in the examples. I think the template code in Boston.rb is...
6 tags
before_filter wisdom
Using Rails’ before_filter is a great way to keep your controller actions clean by moving logic about authentication, authorization, or state of the resource out of the main method, right?
The common wisdom
Here’s a typical usage of before_filter:
class Admin::ArticlesController < ApplicationController
before_filter :deny_access, :unless => :draft_and_admin?
def show
...