0 votes
in Ruby by

Given a table of blog_posts and a related table of comments (comments made on each blog post), which ActiveRecord query will retrieve all blog posts with comments created during @range?

a. BlogPost.joins (:comments).where(comments: {created_at: @range})

b. BlogPost.where(['comments.created_at', @range])

c. BlogPost.preload ("comments.created_at").where(created_at: @range)

d. BlogPost.includes (:comments).where('comments.created_at' => @range)

1 Answer

0 votes
by

Given a table of blog_posts and a related table of comments (comments made on each blog post), which ActiveRecord query will retrieve all blog posts with comments created during @range?

Correct answer is :-  BlogPost.joins (:comments).where(comments: {created_at: @range})

Related questions

0 votes
asked Sep 2, 2022 in Ruby by DavidAnderson
0 votes
asked Sep 3, 2022 in Ruby by DavidAnderson
...