Recognize routes in rails console Session

前端 未结 5 2078
无人共我
无人共我 2020-12-12 10:25

Say I have a router helper that I want more info on, like blogs_path, how do I find out the map statements behind that in console.

I tried generate and recognize and

5条回答
  •  执念已碎
    2020-12-12 10:56

    If you are seeing errors like

    ActionController::RoutingError: No route matches
    

    Where it should be working, you may be using a rails gem or engine that does something like Spree does where it prepends routes, you may need to do something else to view routes in console.

    In spree's case, this is in the routes file

    Spree::Core::Engine.routes.prepend do
      ...
    end
    

    And to work like @mike-blythe suggests, you would then do this before generate or recognize_path.

    r = Spree::Core::Engine.routes
    

提交回复
热议问题