Upgrading to Rails 5.1
Opened this issue · 0 comments
This is the best CMS library I've used and I've tried a few out. however :( after an effort to try and upgrade it to use Rails 5.1 I've sadly not been able to manage it.
If someone out there has managed it or wouldn't mind giving me a few pointers, I might be able to complete the job and would massively appreciate it!
The problem, once I finally removed all of the dependencies, seems to be around url_for_patch. alias_method_chain is no longer allowed in Rails 5.1
module ActionDispatch
module Routing
class RouteSet
if Rails::VERSION::MINOR >= 2
def url_for_with_storytime(options, route_name = nil, url_strategy = UNKNOWN)
Storytime::PostUrlHandler.handle_url(options)
url_for_without_storytime(options, route_name, url_strategy)
end
else
def url_for_with_storytime(options = {})
Storytime::PostUrlHandler.handle_url(options)
url_for_without_storytime(options)
end
end
alias_method_chain :url_for, :storytime
end
end
end
This is where I started, however I'm unable to quite get my head around how the with/without method call get substituted with the code below.
module RouteSetWithURLForStorytime
def url_for(options={})
Storytime::PostUrlHandler.handle_url(options)
super(options)
end
end
RouteSet.send(:prepend, RouteSetWithURLForStorytime)
Any help would be really appreciative.
btw: I used the following article as my inspiration to fix the issues.
https://www.justinweiss.com/articles/rails-5-module-number-prepend-and-the-end-of-alias-method-chain/