Submit buttons are used to submit forms to a controller action. In the controller action you can use the redirect_to
method to redirect to another page.
For example, let's say you have a form for creating widgets. That form would typically submit to the create
action in the WidgetsController
, which could redirect to a listing of widgets that would include the newly created widget:
class WidgetsController < ApplicationController
...
def create
# Do stuff to create the Widget
...
redirect_to widgets_path # Redirects to /widgets
end
end