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

Bad call to route formatter on Rails 5 (WashOut::Router.url) #271

Open
knightq opened this issue Mar 23, 2020 · 0 comments
Open

Bad call to route formatter on Rails 5 (WashOut::Router.url) #271

knightq opened this issue Mar 23, 2020 · 0 comments

Comments

@knightq
Copy link

knightq commented Mar 23, 2020

In lib/wash_out/router.rb: the code on url class method will always raise a NoMethodError in Rails 5 brach, due to a bad param (nil) when calling evaluate.

    def self.url(request, controller_name)
      lookup_soap_routes(controller_name, Rails.application.routes.routes) do |routes|

        path = if routes.first.respond_to?(:optimized_path)      # Rails 4
          routes.map(&:optimized_path)
        elsif routes.first.path.respond_to?(:build_formatter)    # Rails 5
          routes.map{|x| x.path.build_formatter.evaluate(nil)}
        else
          routes.map{|x| x.format({})}                           # Rails 3.2
        end

        if Rails.application.config.relative_url_root.present?
          path.prepend Rails.application.config.relative_url_root
        end
        return request.protocol + request.host_with_port + path.flatten.join('')
      end
    end

Instead of:

routes.map{|x| x.path.build_formatter.evaluate(nil)}

it should be:

routes.map{|x| x.path.build_formatter.evaluate({})}

See also Ruby on Rails 5 implementation for evaluate method called.

aka47 added a commit to aka47/wash_out that referenced this issue Mar 26, 2023
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