I'd like to set a value somewhere to let the view know if it is in "add
new" mode or "Update" mode. Depending on the mode, one line of text in
the view is to be presented differently (e.g. <% if updateMode == true
This brings up a couple of questions:
Where is the best place to store that value?
What is the proper way to set the value in the controller and to
retrieve it in the view?
Instance variables set in the controller are visible in the view. So
you would want to do:
@update_mode = true
<% if @update_mode %>
<% end %>
(Note that you don't need "== true".)
Mind you, if you find yourself doing this a lot, it's probably a sign
that you should reorganize your actions and views, perhaps by
splitting off an update sequence. I've run into situations like that
with @admin_session and other such flags: I realize eventually that
I'm really trying to squeeze two separate use cases into one view,
where it might be better, and scale better, to have a separate suite
of admin tools.