I have the following code in my controller.
def index
@customer = Customer.find(params[:customer_id])
@current_orders = @customer.current_orders
@pending_orders = @customer.pending_orders
@previous_orders = @customer.previous_orders
@recurring_orders = @customer.recurring_orders
end
As you see, all the instance variables(@current_orders,@pending_orders,etc) can be obtain from @customer.
What is the best way to write this code? Should I need to create these instance variable in controller or I just only used these through @customer variable in views.