我想要做的是在一个名为“projects_users”的关系表中使用种子创建帖子,但是在“rake db:seed”之后会引发以下错误:
Expected /...path.../projects_users.rb to define Projects_users
项目_用户.rb:
class ProjectsUsers < ActiveRecord::Base
// no code yet
end
(“projects_users”也有一个控制器和视图(也没有使用))
projects_users 表:
project_id
user_id
项目型号:
class Project < ActiveRecord::Base
has_and_belongs_to_many :users, :class_name => 'User'
belongs_to :user
has_many :tickets, :dependent => :destroy
attr_accessible :user_id, :title, :description, :start_date, :end_date
end
用户型号:
class User < ActiveRecord::Base
attr_accessible :first_name, :last_name, :email, :password
has_and_belongs_to_many :projects
has_many :tickets
before_save :create_remember_token
def create_remember_token
self.remember_token = SecureRandom.urlsafe_base64
end
end
种子.rb:
pu5 = Projects_users.create(:user_id => 12, :project_id => 6)
错误是什么意思,我该如何解决?