我正在编写一些教程,但遇到了一些问题。RubyMine 找不到“:用户”关联的关联 Rails 模型失败
我正在使用:
- RubyMine 7
- Ruby 版本 meneger (rvm)
- ruby-1.9.3-p551 [x86_64]
- ruby-2.1.5 [x86_64]
- rails Rails 4.1.8
- Gem sqllite3
我的模型是:
class Company < ActiveRecord::Base
has_many :users
has_many :projects
end
class Project < ActiveRecord::Base
belongs_to :company
has_many :works
has_many :users, :through => :works
end
class User < ActiveRecord::Base
belongs_to :company
has_many :works
has_many :projects, :through => :works
end
class Work < ActiveRecord::Base
belongs_to :project
belongs_to :user
end
谢玛.rb
ActiveRecord::Schema.define(version: 20141207111312) do
create_table "companies", force: true do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "projects", force: true do |t|
t.string "name"
t.integer "company_id"
t.integer "default_rate"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "users", force: true do |t|
t.string "fname"
t.string "lname"
t.integer "company_id"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "user_id"
end
add_index "users", ["user_id"], name: "index_users_on_user_id"
create_table "works", force: true do |t|
t.integer "project_id"
t.integer "user_id"
t.datetime "datetimeperformed"
t.decimal "hours", precision: 5, scale: 2
t.datetime "created_at"
t.datetime "updated_at"
end
end
我的代码有问题还是 RubyMine 配置有问题?
更新:
如果我使用 Mysql2 或 sqllite3 gem,问题是一样的