Thank you, Dmitry! It is always nice to see who doesn't hide the experience and shares it with a community even though it's not unique. There will be less shit code in the world - what is important!
BTW, I've one remark. Don't use rails_next? outside of Gemfile. Because when you'll do the second and following upgrades then your code will be broken. Use only Rails::VERSION for the checks. I see that you write about that is temporary, but there is always a probability of forgetting about it =)
e.g.:
If we have Rails v4.2 this code is working well.
if rails_next?
method_working_on_5_0_and_higher
else
method_working_on_4_2
end
But after the transition to v5.0 it will be broken.
I suggest always to use clean version conditions.
if Rails::VERSION >= '5.0'
method_working_on_5_0_and_higher
else
method_working_on_4_2
end
Thank you, Dmitry! It is always nice to see who doesn't hide the experience and shares it with a community even though it's not unique. There will be less shit code in the world - what is important!
BTW, I've one remark. Don't use
rails_next?
outside of Gemfile. Because when you'll do the second and following upgrades then your code will be broken. Use onlyRails::VERSION
for the checks. I see that you write about that is temporary, but there is always a probability of forgetting about it =)e.g.:
If we have Rails v4.2 this code is working well.
But after the transition to v5.0 it will be broken.
I suggest always to use clean version conditions.
Hey, Michail! Nice catch, thank you for the note!
It depends on the flow you use. If you clean up all the
rails_next?
checks after any upgrade iteration - it's okayBut checking with
Rails::VERSION
is much flexible I think.