小编sco*_*ott的帖子

UserController#welcome中的ActiveRecord :: HasManyThroughAssociationNotFoundError

我在rails中有很多关系.所有数据库表都相应地进行相应命名.所有模型文件都是复数,并使用下划线分隔单词.所有命名通知都遵循ruby和rails标准.我在我的模型中使用了很多这样的:

has_many :users, :through => :users_posts #Post model
has_many :posts, :through => :users_posts #User model
belongs_to :users #UsersSource model
belongs_to :posts #UsersSource model
Run Code Online (Sandbox Code Playgroud)

这个错误还有什么呢?

ActiveRecord::HasManyThroughAssociationNotFoundError in UsersController#welcome Could not find the association :users_posts in model Post

activerecord many-to-many ruby-on-rails associations has-many-through

18
推荐指数
1
解决办法
7478
查看次数