@workflow_task = WorkflowTask.find(params[:id])
@workflow = @workflow_task.workflow
Is there any issue in the above code? Yes. There are two DB hits in the
above statement. First one is WorkflowTask.find(params[:id]).
Second one is @workflow_task.workflow.
We can reduce this two one DB hit using :include like following:
@workflow_task = WorkflowTask.find(params[:id], :include => [:wofklow]
@workflow = @workflow_task.workflow
The RAILS will do the JOIN.
Just wanted to share with everyone since the ROR new commers might not
aware of this.