Archive for the 'Rails' Category

Controlling Whitespace with HAML

Thursday, July 31st, 2008

When displaying certain elements as inline, the whitespace between tags does matter in your layout.
When trying to display some LI tags as inline, I really needed to spit out the tags with no whitespace in between. Unfortunately HAMLs handy-dandy tag indenting was wrecking me. It was so bad, that I resorted to calling a helper [...]

Using Fixtures with Funky Table Names

Wednesday, July 16th, 2008

If you have an AR Model whose table name does not follow the convention, and you have needed to set it explicitly using set_table_name.

class ChiliDog < ActiveRecord::Base
set_table_name ‘dogs_made_of_chili’
end

Then your test fixtures file must be named the same name as the table, not the model…
dogs_made_of_chili.yml
In your rspec, you must use the table name to [...]

Preventing Callbacks from Firing

Thursday, May 8th, 2008

I have an ActiveRecord class called JournalQuery that performs a large webservice call out to the National Library of Medicine, then caches the result in our local database. Oftentimes, this call can take well over a minute to run, which is not good for the HTTP request/response cycle. In the Rails applicatin got around this [...]

Action Caching with GET Parameters

Tuesday, February 26th, 2008

Ya ever notice how when you do page or action caching in Rails, it ignores the GET query parameters?
Sup with that?
The REST bible says you should include inputs to algorithmic resources as GET query params. Unfortunately, this means that Rails will ignore the inputs to your algorithmic resources, and you can’t cache them. Not so [...]