Forum: Ruby on Rails redirect

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Rick (Guest)
on 2005-12-03 23:17
In one of my controller methods I need to set a flash[:notice] and
redirect back to the form to show the error.

I have this code:

    master_storeids = params[:master_storeid]
    if (master_storeids.nil?)

      flash[:notice] = 'No store was is selected'
      redirect_to :action => 'new_data'

followed by the "normal" code that would be proceesed if no error

Problem is that the redirect doesn't seem to do anything it just
continues on to the remaining code.

I have verified that master_storeids is nil and there is a new_data
method in the controller.
steven.mohapibanks (Guest)
on 2005-12-04 03:14
(Received via mailing list)
The redirect does do something. Any further attempts at rendering or
redirecting should fail.

To be safe just add a return statement after the redirect to complete
the processing.
This topic is locked and can not be replied to.