这些是我的模型:
class Company < ActiveRecord::Base
has_many :products
end
class Product < ActiveRecord::Base
belongs_to :company
has_many :prices
end
class Price < ActiveRecord::Base
belongs_to :product
end
我在路由中将它们定义为嵌套资源
resources :companies
namespace :company do
scope ":company_id" do
resources :products do
resources :prices
resources :production_capabilities
end
end
end
我想将控制器和视图放在与该结构匹配的目录中
app/controllers/companies_controller.rb
app/controllers/company/products_controller.rb
app/controllers/company/product
app/controllers/company/product/prices_controller.rb
一旦我在公司内部创建产品目录并尝试致电
Company.find(1).products
我明白了
NoMethodError: undefined method 'quoted_table_name' for Company::Product:Module
有人知道我在做什么错吗?