RubyFlow : The Ruby Community Blog

Home   Submit   Sign Up   Log In   leaders   Twitter   RSS Feed  
 

ernie — 31 posts

http://erniemiller.org

In Defense of Alias  erniemiller.org
I've been reading a lot of Ruby style recommendations lately, and I wanted to share a relatively unpopular opinion (with some justifications) in preference of "alias" over "alias_method".
I'm convinced that if everyone added these 7 lines to their gem's Rakefile, "steps to reproduce" would become a more common fixture in issue reports.
Wouldn't it be nice if you could write code without making concessions to reality? You can! Well, for a little while, at least. But even then, I think it's worthwhile.
I'm looking for new maintainers for some relatively popular gems that jump through a lot of ActiveRecord hoops.
Ever wondered the lengths to which integrating a gem with ActiveRecord might drive a Rubyist? To these kind of crazy lengths.
The Cost of If  erniemiller.org
Today I made a post about the cost of branching -- in your code, your product, your company, and your life. You might be surprised at how a refactoring pattern for your code might be worth considering in other areas, as well.
Squeel 1.1.0 Released!  erniemiller.org
I just released Squeel 1.1.0, with support for Rails 4!
Confreaks just posted my talk from RailsConf 2013, "An Intervention for ActiveRecord". Video, slides, and SpeakerRate are all right here. If you'd like to take a whirlwind tour of some things that may surprise you about ActiveRecord, please have a look!
Ever wished you could do multipass rendering with Mustache? Ever wonder why you might want to? Ever wondered how the heck Mustache works? Do I have the blog post for you!
I just put together a quick article about an interesting difference between include vs extend of modules when it comes to class variables. Interesting, if not necessarily practically applicable. :)
I just wrote a quick article describing a simple pattern you can employ to reuse string formatting logic throughout your application and avoid making unnecessary regexp comparisons.
I just posted a quick writeup of a pleasant little surprise in the behavior of Ruby's super keyword. In over 5 years of writing Ruby code, I'd never noticed it until now, so maybe it'll be a surprise to you, too!
Making Ruby Dance!  erniemiller.org
I posted video, code, and slides from my lightning talk at Ruby Hoedown, entitled "Making Ruby Dance!". It talks a bit about dependency injection and a particularly evil bit of code. I had a great time with it, so wanted to share. Obviously the video was not professionally recorded, but I think you'll get the idea. :)
Just a quick little post explaining an odd little corner of Ruby: mixing __LINE__ and heredocs in method calls.
An article about a real-world use case for implementing object equality from the ActiveRecord and ARel source code, and a tiny gem that makes implementation less tedious for you, the boilerplate-hating Rubyist.
Earlier today, I posted The Greenfield App Continuum, an article describing some of the philosophical choices we make (or don't) when starting work on a new application.
I wrote an article last night describing a fun little trick that allows you to "escape" from an instance_eval by (ab)using bindings and... more instance_eval.
I just posted details about how Squeel overrides the behavior of backticks in its DSL blocks, along with some of the criteria I used when determining whether or not backticks were a good candidate for the behavior. I hope they'll be useful as a starting point for thinking about overriding just about any default Ruby behavior in your code, especially backticks.
I just posted a quick walkthrough on using attribute whitelisting using the Ransack search gem. But, ignore that part. It was really just an excuse to talk about why a class macro was the wrong way to go about implementing this kind of feature.
Squeel 1.0 Released  erniemiller.org
I've just released version 1.0 of Squeel, the gem that adds all sorts of powerful new querying syntax for ActiveRecord 3.0.x - 3.2.x. It's been over a year in development, so I'm really excited to get it out the door for this RailsConf. Check out this post for details on what's new, and a rundown of some of its nicer features.
Sometimes you don't want Google crawling all over your Rails app, whether it be for load reasons or SEO reasons. Here's a quick article that shows you how to easily default links to rel="nofollow".
I just released a tiny little gem called Valium that makes it simpler to get at your attribute values (properly cast and deserialized) without going through the pain of ActiveRecord instantiation. Here's the blog post.
Benchmarking Enumerable  metautonomo.us
Over the weekend, I did some benchmarking of several Enumerable methods. Some of the results surprised me. They might surprise you, too.
I just put up a quick blog post discussing the upcoming successor to MetaWhere, Squeel. I could really use some testers and feedback on what you'd like to see. If you're running edge Rails, please try it out!
I posted an architectural overview of the MetaWhere 2.0 rewrite-in-progress this morning. If you're interested, head on over -- I'd really appreciate your testing and feedback, particularly on the new DSL!
Everyone knows that alias_method_chain is evil. Sometimes it's a necessary evil. Here's a quick post explaining when the latter is the case.
I just posted an article about attr_bucket, a little gem I should probably never have written that allows you to do evil things to your models. Things like serializing a bunch of attributes into a single "bucket" column, but still support using them with validations and form_for.
After months of development, the MetaWhere and MetaSearch gems for Rails 3 have finally hit 1.0. MetaWhere provides improvements to AR3 query syntax, offering access to ARel predicate methods that aren't available in stock ActiveRecord, support for outer joins, SQL functions, and more, while MetaSearch provides simple object-based searching and sorting for use in Rails forms, and will be a comfortable transition for those used to using Searchlogic in Rails 2.x.
This is a quick tutorial on how to create a mobile version of your Rails app without creating a custom mobile-formatted version of every single layout and template.
MetaSearch is extensible searching for your form_for enjoyment. It “wraps” one of your ActiveRecord models, providing methods that allow you to build up search conditions against that model, and has a few extra form helpers to simplify sorting and supplying multiple parameters to your condition methods as well.
MetaWhere offers the ability to call all Arel predicate methods (matches_any, lt, gt, etc) on your model's attributes instead of the ones normally offered by ActiveRecord's hash parameters. It also adds convenient syntax for order clauses, smarter mapping of nested hash conditions, and a debug_sql method to see the real SQL your code is generating without running it against the database.