coding style - Rails 3 : Anticipating migration for 2.3 beginners -
I'm beginning to run in Rails I use 2.3.X.
I have just seen that Rail 3 has already been released [ Edit: Now in the release candidate! ] I would most likely eventually switch to it.
2.3 What should I do with normal coding, so that the switch is smooth as possible?
Edit:
I have done my homework and have read the release notes. For example:
1.5 new API
Both router and query interfaces have seen critical, breaking changes. The previous compatibility layer is present and will be supported up to 3.1 release.
This is not enough for the start of me like what will break? What can I do earlier in 2.3.X to avoid troubles later?
My personal coding habits (I am using Rail since 1.2.x), here The API is a list of changes that you can guess. Avoid using
Find (: All)
:
Model.find (: All) Model. Find (: first) Model.find (: Last)
in favor of:
model. All models First model.
complex question
Avoid composition complex questions in favor of designated scope.
Forecast of Ariel
Rail 3 provides a very clear approach to dealing with the conditions of the activation and options you hope to make it a custom designated scope can do.
class model named_scope: border, lambda {| Price | {: Border = & gt; Value}} # old way record = model all (: border => 3) # record in new way = model.lid (3). # You can also take advantage of lazy evaluation records = Model.limit (3) # Then in your visual records When the reed {...}
When upgraded to Rail 3, simply leave the designated design scope.
Static
In the favor of the already related Rails.x
methods available in Railing 2.x, the following constants Avoid use.
-
RAILS_ROOT , -
rails in favor of Rails.root. Rails.env in favor of ANV
RAILS_DEFAULT_LOGGER
Incredible JavaScript
Avoid heavy JavaScript helpers in favor of incredible javascript.
Gem Dependencies
Keep your
Environmental Rb
as easy as possible to make the bundler easier for migration. You can also hope for migration without Rail 3.
Comments
Post a Comment