Rails: how to use scope with params and use route with default value of params

前端 未结 1 1355
暗喜
暗喜 2020-12-28 17:29

I have such lines in routes.rb:

scope \"/:subdomain/\" do
  resource :order, :only => [:new, :create, :show, :update, :edit, :destroy] do
    get   :cance         


        
相关标签:
1条回答
  • 2020-12-28 18:25

    The answer is "use () and defaults"

    scope "/(:subdomain)", :defaults => {:subdomain => "default"} do
      ...
    end
    

    http://guides.rubyonrails.org/routing.html#dynamic-segments and http://guides.rubyonrails.org/routing.html#defining-defaults

    0 讨论(0)
提交回复
热议问题