代码之家  ›  专栏  ›  技术社区  ›  CodeSmith

Rails 5.1“模糊路由定义。两者:路径和指定为字符串的路由路径。(ArgumentError)”

  •  2
  • CodeSmith  · 技术社区  · 7 年前

    在Rails 5.0.5上,以下路线定义有效

    get 'terms_of_use', to: 'pages#terms_of_use', path: "terms-of-use"
    

    /home/dev/.rvm/gems/ruby-2.3.3/gems/actionpack-5.1.3/lib/action_dispatch/routing/mapper.rb:1852:in `block in map_match': Ambigous route definition. Both :path and the route path where specified as strings. (ArgumentError)
    

    我正在使用 path: Rails 5.1.3不正确,或者这是Rails错误?

    1 回复  |  直到 7 年前
        1
  •  2
  •   Stephane Paquet    7 年前

    请尝试以下操作之一:

    get :terms_of_use, to: 'pages#terms_of_use', path: 'terms-of-use'

    get 'terms-of-use', to: :terms_of_use, controller: 'pages'