On Nov 25, 2007, at 4:18 PM, doug wrote:
Let me re-phrase that to make sure that I understand:
You have one view that has no default association with any controller
action (i.e., the view does not have the same name as any controller
action). However, the one view is associated on a non-default basis
(presumably by means of render) with several different actions. Then
you use each action to configure what your one view is going to do.
Cool. You also could have had your view be the default view for one
of your actions, right?
The application is an in-house one, and when something unusual happens
we need a special way to handle those events for a given client.
It’s outside of the normal work-flow, and they don’t come up often but
I had to make a way to quickly deal with it.
So I have a file called set_client.rhtml, which contains a one-field
form.
I have no set_client method in my controller. Other methods will do
something like this:
@headline = "Send money to this client"
@action_to_call = "special_payment"
render :action => :set_client
I’m not allowed to use any Javascript, and before they can actually
handle the problem the person usually has to review a list of items
related in one way or another to this client. So this way I can take
them to the proper place and at the same time show the the correct
list of items.
The form looks something like this:
<%= @headline.titlecase -%>
<%= form_tag :action => @action_to_call %>
<%= text_field_tag :client_id, params[:client_id] %>
<%= submit_tag "Next..." %>
<%= end_form_tag %>
And so the submitted form will go where ever @action_to_call says.
I’m sure there’s a more clever way to handle this, but this does what
I need for those out-of-the-normal-flow cases.