Rails路由:参数数量错误(3表示1)

时间:2016-01-06 07:54:01

标签: ruby-on-rails ruby-on-rails-4 routing routes subdomain

这是我第一次尝试在Rails项目中使用子域名。我计划有这样的路线:

  1. example.com/about-us(静态页面)
  2. example.com/contact-us(静态页面)
  3. app.example.com
  4. app.example.com/orders
  5. 我在 routes.rb 文件中有这个:

    Rails.application.routes.draw do
    
        constraints :subdomain => "app" do
            resources :orders
        end
    
      root "orders#index"
    end
    

    这是我的佣金路线的结果:

    Prefix     Verb   URI Pattern                Controller#Action
        orders GET    /orders(.:format)          orders#index {:subdomain=>"app"}
               POST   /orders(.:format)          orders#create {:subdomain=>"app"}
     new_order GET    /orders/new(.:format)      orders#new {:subdomain=>"app"}
    edit_order GET    /orders/:id/edit(.:format) orders#edit {:subdomain=>"app"}
         order GET    /orders/:id(.:format)      orders#show {:subdomain=>"app"}
               PATCH  /orders/:id(.:format)      orders#update {:subdomain=>"app"}
               PUT    /orders/:id(.:format)      orders#update {:subdomain=>"app"}
               DELETE /orders/:id(.:format)      orders#destroy {:subdomain=>"app"}
          root GET    /                          orders#index
    

    当我尝试访问http://app.rails_subdomain.dev/orders/时,我收到此错误:

    enter image description here

    当我尝试访问http://app.rails_subdomain.dev/orders/1时,我收到此错误:

    enter image description here

    我在这里缺少什么? wrong number of arguments (3 for 1)错误在这里意味着什么?

    注1 :在创建路径文件之前,我已经运行rails g scaffold orders name并且已经运行rake db:migrate

    注意2 :我正在使用Pow

0 个答案:

没有答案