ruby on rails - Using associations with pluck -
im trying array project name , task title. task title in projects model. should use pluck or select or where?
@completed_tasks = task.where(completed:true).select("projects.project_name", :title)
first of all, should use join
data projects table. , can use either pluck
or select
.
for example (suppose in task
model have belongs_to :project
)
@completed_tasks = task.where(completed:true).join(:project).select("projects.project_name", :title)
Comments
Post a Comment