Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8080515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:26:14+00:00 2026-06-05T16:26:14+00:00

I want to be able to do the following actions with a form submit

  • 0

I want to be able to do the following actions with a form submit using respond_with:

  1. Submit then redirect to index
  2. Submit then stay in the form
  3. Submit and show the created record

the default action for respond_with is to redirect to the show action. How can I make the controller respond depending on the type of button clicked?

these “submits” will occur during create and update actions. For example, how would the create action in this code respond to whichever among the three submit buttons is clicked(Submit and Edit, Submit and Show, Submit and Show INdex)

def new
    respond_with(@business=Business.new)
  end

  def create
    @business = Business.new(params[:business])
    flash[:notice] = t("flash.actions.create.notice", {:resource_name => "Business"}) if @business.save
    respond_with(@business)
  end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T16:26:16+00:00Added an answer on June 5, 2026 at 4:26 pm

    In your view, using the values submit_and_edit, submit_and_show and submit_and_show_index, you would do this in your controller:

    def create
      @business = Business.new(params[:business])
      flash[:notice] = t("flash.actions.create.notice", {:resource_name => "Business"}) if      @business.save
      location = case params[:submit]
      when 'submit_and_edit'
        edit_business_url
      when 'submit_and_show'
        business_url
      when 'submit_and_show_index'
        redirect_to businesses_url
      end
      respond_with(@business, :location => location)
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to be able to achieve the following using guice/gin: Get all sort
I want to be able to parse the following times using ParseExact() function: 01:02:03
I want do be able do update some values direct form the index view
I want to be able to post the following form without the page refreshing
I want to be able to do the following: NSString *hoursAndMinutes = [myNSDateObject formattedTime];
I want to be able to do the following: get '/:slug' do haml :page
I want to be able to initialize a CArticle having the following properties: Private
I have the following migration and I want to be able to check if
I'm using LaTeX and BibTeX for an article, and I want to able to
When a user saves a form, I want to do the following check before

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.