How do I stop controller execution after using redirect_to? (Using Rails) How do I stop controller execution after using redirect_to? (Using Rails) ruby-on-rails ruby-on-rails

How do I stop controller execution after using redirect_to? (Using Rails)


You can also do:

return redirect_to :action => 'index'

and

return redirect_to :action => 'month_index',   :year => Date.today.year,   :month => Date.today.month,  :type => params[:type]

since it looks nicer than putting return on its own line (IMHO).


You probably want to use filters.

If you call your check_date as a before_filter in the controller, the fact that it rendered or redirected will prevent the controller from ever calling the action method. It ends there and then.


You can throw in

return false

wherever you want the code execution in your action to stop