@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.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---