Here’s a quick tip to exert greater control over which parts of your site a search engine should crawl: modify your link_to helper to make links rel="nofollow" by default. It’s easy:
Read the rest of this post
No, I don't work in NYC, DC, or the valley, and I'm cool with that.
Here’s a quick tip to exert greater control over which parts of your site a search engine should crawl: modify your link_to helper to make links rel="nofollow" by default. It’s easy:
Read the rest of this post
Just a quick update about Valium 0.4.0. In 0.3.0, I enabled support for extracting attribute values from associations (a la User.posts[:id]). That was awesome, but as it turns out, not too compatible with 3.0.x associations.
Read the rest of this post
No, not the drug — the Ruby gem! Have you ever written code like this?
Model.where(:attribute => 'value').map(&:id).each do |model_id| # ... end
I’m guessing you have, even if only as you were just getting started learning Rails/Ruby. It’s a bad idea.
Lately, I’ve been spending some time filtering data sets in Ruby. A common pattern when filtering data on multiple criteria involves short-circuiting processing at the first match or non-match, depending on whether conditions are being evaluated in an any/or or all/and context, respectively. As a result, I thought I’d run a few quick benchmarks on several implementations of this pattern. The results surprised me, so I thought I would share them here. Read the rest of this post
Why, I’m glad you asked! It’s been a while since I’ve made any updates about Squeel — since before RailsConf, actually! A lot’s been added since then.
Read the rest of this post
I just read the blog post that got some traction on HN last night, entitled “What the hell is happening to rails?” It goes on to list a litany of complaints against changes in Rails 3.x, ranging from the default commenting of the catch-all route to, yes, of course, CoffeeScript. They all end up sounding a lot like “I don’t like change,” an argument we’ve all heard before. The difference is that Steve Coast, the post’s author, casts himself in the role of a crusader for the newbies. He says that he, personally, “gets” why these changes were made, but that the most recent versions of Rails are actually harder to learn than the older ones were. The post highlighted two things, to me:
So, I conducted an introduction to Ruby on Rails workshop last night and just finished up a list of book recommendations for the attendees. I thought I’d share them here, in case anyone is looking for a few good starter books to learn Ruby on Rails. I went with 2 recommendations for Ruby, and 2 for Rails, because It’s really important to understand Ruby if you’re going to start hacking away at Rails. A deeper knowledge of Ruby helps make all the Rails “magic” more understandable.
Read the rest of this post
Recently, I stumbled upon a fork of one of my projects in which someone made a really intelligent-sounding commit: “Remove needless indirection of alias_method_chain.” He used the term indirection, so I was duly impressed, and my curiosity was piqued: had I sinned against the programming gods and used an alias_method_chain when it wasn’t needed? No, I hadn’t. alias_method_chain is frequently abused in the Rails world, but it wouldn’t exist if there wasn’t a valid use case.
Read the rest of this post
Good evening, Internet! I hope you had a wonderful and productive workday. Now, with those pleasantries out of the way, I’d like to point you in the direction of a little gem called attr_bucket that I am regretful for having written even as I type this blog post suggesting you go try it. That is because this gem, while tiny and unassuming, has tremendous potential for evil.