Here is my controller
@post = Post.joins(:customers).select("customers.*,posts.*").find params[:id]
My post model
belongs_to :customer
My customer model
has_many :posts
And i am getting error as
Association named 'customers' was not found on Post; perhaps you misspelled it?
This is my controller output:
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'
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…