这是我的控制器
@post = Post.joins(:customers).select("customers.*,posts.*").find params[:id]
我的帖子模型
belongs_to :customer
我的客户模型
has_many :posts
我得到了错误
Association named 'customers' was not found on Post; perhaps you misspelled it?
这是我的控制器输出:
Processing by PostsController#show as */*
Parameters: {"id"=>"6"}
Post Load (0.5ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = $1 LIMIT 1 [["id", "6"]]
Completed 500 Internal Server Error in 113ms
ActiveRecord::ConfigurationError (Association named 'customers' was not found on Post; perhaps you misspelled it?):
app/controllers/posts_controller.rb:16:in `show'