Category Archives: Rails
Quick Hits: Sass demands syntax perfection!
Just a quick note about sass. Let’s say you had the following in /public/stylesheets/sass/foo.sass: body line-height:1.2em h1 color:red This would render a blank document for /public/stylesheets/foo.css. You won’t get an error about it, you’ll just get a blank document. Here’s … Continue reading
Quick Hits: Things to keep in mind
(1) Before you unpack your gems, navigate to your vendors directory: /Users/[yourname]/[your-app]/vendor/gems: gem unpack [gem name] It isn’t the end of the world if you don’t do it ahead of time, but it does make life slightly easier. (2) Remember … Continue reading
Rails Gotcha: ActiveRecord Caches Associated Records by Default
ActiveRecord will cache the results of association method calls by default, unless you tell it not to. (This applies to Rails 2.3.2 and perhaps earlier versions.) From the documentation: project.milestones # fetches milestones from the database project.milestones.size # uses the … Continue reading
Quick Hits: Setting the User Agent Header in Webrat
If you’ve read the new PragProg beta e-book on RSpec, you may have read that you can set HTTP headers for your Webrat request like so: Given /^I am browsing the site using Safari$/ do header "User-Agent" , "Mozilla/5.0 (Macintosh; … Continue reading
FasterCSV and noob-ish silliness
Here are two things I discovered this weekend: Thing 1: FasterCSV is really cool! It’s easy to use and does exactly what it should. Here’s Scott Becker’s exporting tutorial. For importing, i’ve hacked together bits from Peter Larkmund’s travels and … Continue reading
F@#$ing get V1 out
I’m not new to software development, but unlike Gabe and Brad I’m new to hacking rails. I’ve created simple tutorial apps in rails (an online store, a blog, etc.) and I now feel comfortable enough to create something for the … Continue reading
Using assert_select to find an attribute that has square brackets in the value
Problem: assert_select ‘input[name=model_name[field_name]]’ gives ArgumentError: Invalid selector: ] Solution: assert_select ‘input[name=?]‘, ‘model_name[field_name]‘ Thanks to the Boston Ruby Group thread for the answer. Bonus: Here’s a helpful assert_select cheat sheet.
InvalidAuthenticityToken, Forms, Tables, and Rails
Recently, while pairing with Abel as we hacked on some code for his budget tracking app, we came across an interesting problem while trying to acomplish what seems like a pretty straightforward task.
Better Rails Searching with Named Scopes using Scope Builder
When it comes writing elegant search code in a Rails app, Named Scopes immediately come to mind. And for good reason: they’re a fantastic way to express, well, scopes, for your searches. In your Person model, you might have named … Continue reading