On 17 March 2010 15:55, Michael Pavling <pavl...@gmail.com> wrote:
> On 17 March 2010 15:41, Clay H. <cchea...@gmail.com> wrote:
>> How do I either:
>> 1) Detect which action/view/template sent the user to the create
>> action, so that I can conditionally return them to the proper action
>> using render?
>>
>> or
>>
>> 2) Use redirect_to(:back) and still show the validation errors?
>>
>
> The RESTful way is to have a "dispense_stock" controller - which has
> its own methods.
>
> The cheaty (smelly) way is to put a hidden field in the form or an
> extra querystring parameter with with the value "new" or "dispense",
> and check the params hash for the value.

Whether this is smelly or not really depends on how similar the two
actions are.  As I understand it they both create a new record in the
same table, so it _could_ be virtually (or even completely) odour free
to use the same action and determine the details of what to do based
on parameters (it may not even be necessary to add a new parameter, it
may be implicitly clear from existing parameters).  On the other hand
I agree that route could cause an offensive effluvia to exuded.  It
all depends on the detail.

Colin

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to