我确信这是 RoR 中的一个基本问题,但我添加了一个名为 hooods_one_providers 的新表。该表没有对应的模型 - 它应该连接两个模型 - Providers 和 Hoods。我试图在控制台中调用它,但得到的是 - 未初始化的常量。
当我运行时:
ActiveRecord::Base.connection.tables
=> ["schema_migrations", "users", "roles", "users_roles", "providers", "food_items", "food_items_users", "feedbacks", "addresses", "carts", "link_carts", "hoods", "drink_items", "addons_ons", "addons_nears", "customize_foods", "addresses_hoods", "hoods_one_providers"]
我可以看到表格,但我无法从中读取。当我运行 hooods_one_providers 我得到未初始化的常量错误:
NameError: uninitialized constant HoodsOneProvider
from (irb):14
from /home/ido/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.9/lib/rails/commands/console.rb:47:in `start'
from /home/ido/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.9/lib/rails/commands/console.rb:8:in `start'
from /home/ido/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.9/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
在模型提供者中,我有:
has_and_belongs_to_many :hoods_one, class_name: 'HoodsOne'
在模型引擎盖中,我有:
has_and_belongs_to_many :providers
将不胜感激任何帮助。谢谢