- ARCHIVE / Rails
- Why freeze when you can symlink
Just a quick thought: for a while now, I’ve been putting this in my Capistrano recipe, in the :after_update_code task:
run “cd #{release_path} && rake rails:freeze:edge TAG=rel_1-2-4″
But what’s the point in exporting the same 5Mb of files every time you deploy? Instead, let’s do this:
run “ln -s #{release_path}/../../shared/rails/1.2.4
#{release_path}/vendor/rails”
cd into your Capitrano shared [...] - LabelHelper is now part of Rails core
It’s official — as of changeset 7541, I’m a Rails Contributor. Hurrah! and so forth. LabelHelper, my plugin for DRY-ing up label tags in forms, is now in Rails core and will presumably be part of Rails 2.0 when it comes out. Now how’s about we get some of these committed as well? Oh, and [...]
- String#toFunction for Prototype
As everybody is no doubt aware, there are new rules for getting a patch into Rails. With that in mind, I thought I’d share some of my patches here in the hopes that one of my army of readers (ha!) will find something I wrote interesting enough to try out for themselves. I’ve got a [...]
- Mixing other languages into your Rails app for local development
For my current project, I thought it might be nice to offload a few Ajax calls onto something other than my app’s Ruby process - that can only handle one request at a time, and Ruby is notoriously slow, so I didn’t want to bog it down with some niche things that could take over [...]
- How to fix bugs in software the hard way, or, why open source software is so damn helpful
If nothing else, this week has taught me a few things about bug fixing. As I’ve written about before, my IncludeByDefault plugin (or, more accurately, the project I’m using it for) exposed a bug or two in Rails. Revision 17 is the result of a very messy process trying to chase a bug up and [...]
- IncludeByDefault progress
IncludeByDefault, as mentioned in my last post, hit some snags with ActiveRecord generating duplicate table aliases when doing cascaded includes, e.g.
Tag.find(8).posts.find(:all, :include => :tags)
So, I set out to work around it, only to run into further problems. I went with option C: let find operations get all the way to the database, and then catch [...] - Including in circles
Not long had I been using my new plugin when I discovered it made this happen when trying to eager-load on a many-to-many association:
SELECT DISTINCT news_stories.id
FROM news_stories
LEFT OUTER JOIN countries_news_stories
ON countries_news_stories.news_id = news_stories.id
LEFT OUTER JOIN countries
ON countries.id = countries_news_stories.country_id
INNER JOIN countries_news_stories
ON news_stories.id = [...] - New Rails plugin: IncludeByDefault
It’s true, I’m a plugin writing machine. Seriously though, this one’s tiny. I took all of five minutes to write. What it does is, it lets you specify a default value for the :include option on ActiveRecord::Base.find, so you can automate eager loading of associations. I’ll use an example I’m comfortable with:
class BlogEntry [...] - Automating JSON evaluation in Rails
As I’m sure many of you already know, Prototype (Rails’ JavaScript framework) will automatically eval() JSON from Ajax responses if you pass it in the X-JSON header. It even says so right here. The Rails team don’t want to automate this on the server side as recent versions of Prototype are moving away from this [...]
- Grape will ignore a few things now
Another update to Grape: it will now ignore the doc, log, tmp and vendor/rails directories in its searches. No point crawling through the huge files that can build up in log or tmp, and doc is mostly auto-generated anyway. I have a habit of keeping large photoshop files and database backups in the doc folder [...]