Get Your App Ready for Rails 4
rubysource.com
rubysource.com
http://blog.remarkablelabs.com/2012/12/what-s-new-in-active-...
The official edgenotes has sections for all the Active components:
find_all_by_user_id_and_conversation_id(params[:user_id], @conversation.id)
But this is equally (actually more) concise: where(user_id: params[:user_id], conversation_id: @conversation.id)
...and it builds on the composable scope system (derived from ARel).Several of my talented friends spend too much time precariously managing their old Ruby codebases. I hope it keeps improving to make life easier.
Any fast-evolving framework is a bit of a moving target - see android and iOS as well, not to mention HTML5, jquery, apps written in anything fast-moving needs constant minor maintenance to keep up. That said, there's no reason a rails 1 app won't run today just like it always has.
One of the reasons rails can move so fast while avoiding bloat is its aggressive cutting of deprecated code. That has always been part of the rails way and I believe most rails devs are strongly in favour of this policy.
Most gems simply don't provide changelogs. Virtually none will maintain compatibility with more than one version of Rails, despite how easy monkey-patching makes this. So, if you care about fixing security releases in your app, you need to maintain not just Rails, but also the code for every plugin you use.
In one case I was told if I wanted the latest toys, I should upgrade to Rails 3, even when I offered to provide the Rails 2.3 compatibility branch. It's not a technical problem, it's a cultural one (and to be fair, those with opposing viewpoints don't view it as a problem). But, at the end of the day it's just not worth the headache.
You need to ruthlessly cut your dependency graph or accept the potentially destabilizing upgrade.
If what is today's leading edge will be legacy in the next 8-12 months, can a codebase get established and create value?
For my part, I avoid anything that's a Rails plugin now. Time after time, I've found them to be a problem. Even if you decide you're going to upgrade to Rails 4, you need to update your entire dependency graph in one pass. Plugins targeting Rails 4 almost certainly won't target 3.x and not all plugins are going to be 4 ready on release day, so upgrading piecemeal is impossible.
The only issue has been with our deployment environment — there is just too much effort required to support both 1.8.7 and 1.9.3 on the same box, so this particular app is still running on separate boxes that are configured using legacy Puppet scripts.
With a mindset of today's leading edge "way" being tomorrow's legacy.. one is creating technical debt that will be abandoned on older versions without extensive updates.
A black and white view on a framework being opinionated definitely costs more developer hours in some ways (which it could save up front).
I want to be extremely careful to not go near any religious debates about frameworks, or as you put it very well, preferences.
There is no perfect or ideal tool. Having open enough conversations about the tools we use and the reality we sometimes face without trying to be apologists or explain it away is essential.
I do wonder if many people have yet to have a relationship with a codebase they started as the leading edge, which stays stuck on an old release that becomes more and more expensive to upgrade. Does one really end up ahead in that case having to repay technical debt caused by the philosophy of a framework?
Maybe there's a finer line that can be drawn between the fantastic benefits of a framework that are not likely to change, and a way to work in approaches that may come and go?
Like any framework, it will have mature whether it likes it or not, I just hope it's for the better like everyone.
I didn't include queues, live streaming, and other features because unfortunately they are not available as a separate gems.
I tried to cover all the things that are possible now (via gems or simple code change). Maybe in a future post I'll cover all the new things in Rails 4. But as it's still on development I prefer to wait until a beta or release candidate.
Excellent post BTW.
# Bundle edge Rails instead:
gem 'rails', :git => 'git://github.com/rails/rails.git'
Does anybody know how this technique affects SEO?
The removal of 'match' in routes is a little saddening....
I'm not sure how I feel about the concerns abstraction.