This might be a noob question. But I couldn't figure it out by myself.
In my application' I'm using Rails 3.2.8 with Mongoid and MongoDB.
I have a instance variable like this:
ProgramsController < ApplicationController
@program = Program.find(params[:id])
In my view file, I need to use it many many times. For example;
@program.title
@program.content
@program.schedules (associated with Schedule model)
@program.articles (associated with Article model)
etc.
The issue is, I need to use that instance variable at DIFFERENT parts of the view. So it's not something like doing a @program.each do |t| ....
BUT when ever I use @program at a different part of the view, that means a NEW query each time...
At the moment I have 31 queries for my view. Isn't it too much?
So what is the best practice? How should I use instance variables effectively?
Thanks in advance.