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 8101047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:53:24+00:00 2026-06-05T22:53:24+00:00

I have a create method in one controller and at the end of this

  • 0

I have a create method in one controller and at the end of this controller I want redirect_to another controller/view. How will I be able to display a flash[:notice] after the first controller is done and the next redirect_to view is rendered?

Here’s the code in the first controller:

if @list.save
        redirect_to root_path, :notice => "Created!"

I also noticed that it doesn’t work here either:

if @list.save
    redirect_to root_path, :alert => "Created!"

Here’s the routes file:

root :to => 'sessions#new'
  • 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-05T22:53:26+00:00Added an answer on June 5, 2026 at 10:53 pm

    To persist a flash message over an additional request you can use flash.keep – from the flash section on Rails Guides:

    Let’s say this action corresponds to root_url, but you want all
    requests here to be redirected to UsersController#index. If an action
    sets the flash and redirects here, the values would normally be lost
    when another redirect happens, but you can use ‘keep’ to make it
    persist for another request.

    Clarification: This solution only applies if you’re losing the flash due to a double redirect.

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

Sidebar

Related Questions

I have following spec to test controller method: context #create do it should redirect
I have this method call: public DataTemplate Create(Type type, string propertyName) { string str
Hi I want to create a WCF service that have login method, which is
I have this code working in C#: var request = (HttpWebRequest)WebRequest.Create(https://x.com/service); request.Method = GET;
I have created a new method in one of the project's controllers that it
I have a winforms, and it connecting wit webservice. Webservice has method which create
I have a web service method in which I create a particular type of
I create small application which is media player. I have method where I have
I'm trying to get my head around this one: Say you have two models
I have a model, Product, and on the show view for this model, I

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.