【问题标题】:Rails 5.0.0.1: Why does match controller in my routes file not workRails 5.0.0.1:为什么我的路由文件中的匹配控制器不起作用
【发布时间】:2016-09-27 09:21:20
【问题描述】:
Rails.application.routes.draw do
    #get 'welcome/index'
    #get 'welcome/sample'
     match ':controller(/:action(/:id))', : via => :get 

  # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html


    root 'welcome#index'

end

比赛控制器部分不允许我去路由welcome/sample或welcome/index

【问题讨论】:

    标签: ruby-on-rails routing ruby-on-rails-5


    【解决方案1】:

    您的代码适用于我,但 : via 应该是 :via
    另外我建议您使用get 而不是match。见rails github guide(谢谢@ABPrime)。

    get ':controller(/:action(/:id))'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多