Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrading to Rails 5.1 #211

Open
uksa opened this issue Feb 18, 2018 · 0 comments
Open

Upgrading to Rails 5.1 #211

uksa opened this issue Feb 18, 2018 · 0 comments

Comments

@uksa
Copy link

uksa commented Feb 18, 2018

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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant