开发者

Best Practice for Detecting Rails Version for Plugin Compatibility?

开发者 https://www.devze.com 2023-02-13 23:32 出处:网络
I\'m working on upgrading a plugin for Rails 3.0.5, specifically, this commit.Essentially, ActiveRecord requires a proc instead of a string for condition interpolation.

I'm working on upgrading a plugin for Rails 3.0.5, specifically, this commit. Essentially, ActiveRecord requires a proc instead of a string for condition interpolation.

In general, I think the best way to handl开发者_Go百科e something like this is with a respond_to? call, but in this case all of the methods that were changed are private. What's the best practice for checking the rails version so that the plugin can give new versions a proc, and old versions a string? I'd rather not rely on checking that private methods exist, since that is likely to break in the future.


Rails.version
# => "3.0.5"
Rails::VERSION::MAJOR
# => 3
Rails::VERSION::MINOR
# => 0
Rails::VERSION::TINY
# => 5
0

精彩评论

暂无评论...
验证码 换一张
取 消