Rails Components Abandoned

I’ve been hearing from several places now, including DDH that the ‘components’ folder in all our Rails installations is becoming decreasingly useful. That’s quite a feat considering 89% of all Railers never knew what Components were all about anyway.

What Are Components?

As far as I understand it components allow you to implement the result of a controller request inside another. Just as partials allow you to put views within views components allow you to render a whole http response from a controller inside the view of another.

I’ve heard of shopping cart systems considering a solution like this. It would allow for a persistent cart session happening on the side of the page while allowing you to keep the actions of multiple controllers distinct.

Why are they disappearing?

I really like what DHH said in the above link: “The problem with components is that they’ve never actually been in style. We just forgot to tell people that. Our bad, now being rectified.” So, for starters, they were never popular.

The other main reason is that Railers who have implemented components are noticing themselves refactoring away from them. It’s becoming clear that, in most circumstances, plugins or helpers or possibly even an engine would serve an application better than components.

Lastly, they’re slow. Blecchhh. That’s a show-stopper.

Why do I bring this up?

If you’re reading this post within the first few days you might notice that my theme has changed. I was using Hemmingway (hard to read but at least it had soul) and now I’m using… well, I’m using one of the only themes that still works. When I updated Typo (I ride the trunk) today I saw that there had been some significant work done on the components: namely, they’ve been removed. The folks in the TypoSphere have made some substantial improvements to the code on their way to Typo 4.1. One of these is a much, much better sidebar system that doesn’t rely on components.

Don’t believe me? Take Pier’s word for it.

Now, if I can just figure out how to fix my themes…

  • Labrat said: Funny, this situation looks familiar. Piers knocked out the issues so the latest trunk should be kosher (scribbish works...). I've briefly glanced at components myself, before finding out partials were the thing. Part of the problem is that newbies like myself are still walking through Agile Web Development with Rails first edition while the cool kids surf the edge. Oh well...
  • Danger said: I know how you feel about getting left behind. Every time I learn something new it turns out I'm still 3 steps behind the current trends. Now that Piers has had a chance to look at it I might try another update. Thanks Labrat.
  • Danger said: Also, it's funny to me that while looking for a new theme just now I happened to choose (on aesthetics alone) precisely the one you said is known to work. Scribbish should be here any minute now.
  • Ben said: I heard in an interview that DHH that components were one of the only features in Rails that was not extracted from an application. It was an idea that they came up with and implemented in isolation. He was saying that's the last time they'll do that, and all new features in Rails will be extractions. This is what I love about Rails. So many things in Java are designed by committee. Case in point, the biggest failure in Java ever, EJB. They spent years coming up with specs, and trying to design the ultimate distributed persistence architecture, and it sucked, big time. RE: being left behind. Trust me Danger, just because you see the core guys talking about the new shit, doesn't mean you're behind. Rails is the edge.
blog comments powered by Disqus