文件名 -
app/controllers/invoice/inventory/department/pharmacy_invoices_controller.rb
文件内容-
class Invoice::Inventory::Department::PharmacyInvoicesController < ApplicationController
...
end
Run Code Online (Sandbox Code Playgroud)
我在开发中没有收到错误,但在生产中却收到此错误 -
F, [2016-04-25T13:08:00.754597 #13500] FATAL -- :
LoadError (Unable to autoload constant Invoice::Inventory::Department::PharmacyInvoicesController, expected /xxxxxx/yyyyyyy/app/controllers/invoice/inventory/department/pharmacy_invoices_controller.rb to define it):
Run Code Online (Sandbox Code Playgroud)
我做了 ssh 并检查了服务器上的每个文件。这和开发是一样的,这是显而易见的。我不明白为什么它会在生产中抛出这样的错误。
我想在我的mongodb数据库中列出所有具有相应集合的模型?我正在使用mongoidgem for MongoDB.
我会尝试这样的事情
ActiveRecord::Base.send :subclasses
哪个工作正常,但我没有使用ActiveRecord.
我有以下设置来处理类别和子类别。
类别.rb
class Category < ActiveRecord::Base
extend FriendlyId
friendly_id :name, use: :slugged
has_many :subcategories
has_many :products ,:through => :subcategories
end
Run Code Online (Sandbox Code Playgroud)
子类别.rb
class Subcategory < ActiveRecord::Base
belongs_to :category
has_many :products
end
Run Code Online (Sandbox Code Playgroud)
产品.rb
class Product < ActiveRecord::Base
acts_as_taggable
extend FriendlyId
friendly_id :name, use: :slugged
belongs_to :subcategory
end
Run Code Online (Sandbox Code Playgroud)
我是否需要添加一个category_id:integer & subcategory_id:integer到产品模型中才能使其工作,或者Rails会自动为我处理这个问题吗?