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

  • SEARCH
  • Home
  • 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 7662927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:55:35+00:00 2026-05-31T13:55:35+00:00

I have a controller that deals with contact emails. I have an action like

  • 0

I have a controller that deals with contact emails. I have an action like this:

def representative
    @contact = UserContact.new()
    if request.method == 'POST'
     @contact = UserContact.new(params[:merchant_contact])
     if @contact.valid?
      @contact.contact_email = current_user.email
      @contact.contact_phone = current_user.phone_number
      Emailer.representative_contact(@contact, representative).deliver # sends the email
          redirect_to **????**, :flash => { :notice => "Thank you! Someone will get back to you shortly."}
     else
      render :representative
     end
    else
     render :representative
    end
end

I call contact_representative_path from different places in my code, and I want that, after submission a redirection to where the user clicked the contact_representative_path. I have tried with :back, but it just renders the representative view.

  • 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-05-31T13:55:36+00:00Added an answer on May 31, 2026 at 1:55 pm

    redirect_to and return does not end the requests, in order to end the request you need to add return at the end.

    Try with redirect_to contact_representative_path,:flash => { :notice => "Thank you! Someone will get back to you shortly."} and return

    UPDATE

    In session hash, you can store the requesting url which will be available across multiple requests.
    session[:return_to] ||= request.referer
    Then call redirect_to session[:return_to], :flash => { :notice => "Thank you! Someone will get back to you shortly."}

    Check this question, hope this will solve your problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a controller that looks like this: public class PageController : Controller {
I have a request controller that is getting out of hand, and I want
I have a method in my controller that handles generic page requests, meant for
I have an article controller that deals with articles. I have a comment model
I have a controller#action that defines an instance variable: @min_rating = 4 In the
I have a controller with a method that handles incoming GET data, stores some
I have a controller that runs some calculation on data, and then I need
I have a controller that contains a tableView that spawns another controller modally to
I have a controller that is called with AJAX (sends JSON data), so I
--Summary (shortened)-- I have a controller that loads a profile object from the corresponding

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.