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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:38:54+00:00 2026-05-29T09:38:54+00:00

I’m trying to render only a flash message without a redirect or render after

  • 0

I’m trying to render only a flash message without a redirect or render after a Create action:

  def create
    @subscriber = Subscriber.new(params[:subscriber])
    if @subscriber.save
      success = true
      message = "Thanks!"
    else
      success = false
      message = "Sorry, there was an error."
    end

    respond_to do |format|
      format.html {
        if success
          flash[:success] = message 
        else
          flash[:error] = message
        end  
      }  
    end
  end

With this code I get a Template Missing error. I don’t want to refresh the same page either. How do I show the flash message without refreshing the page and without getting the template error?

  • 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-29T09:38:56+00:00Added an answer on May 29, 2026 at 9:38 am

    When you don’t redirect_to any other action, then you should have a view named create.html

    The common practice here is to redirect somewhere like root_path, or to subscriber profile or whatever

    And yes, to show just flash message, you could use AJAX, then you controller action will look smth like:

    def create
      @subscriber = Subscriber.new(params[:subscriber])
      success_msg, error_msg = "Thanks!", "Sorry, there was an error."
    
      respond_to do |format|
        if @subscriber.save
          format.html { redirect_to root_path, :success => success_msg }
          format.js { render :js => your_javascript_to_show_the_message_here }
        else
          format.html { redirect_to root_path, :error => error_msg }
          format.js { render :js => your_javascript_to_show_the_message_here }
        end
      end 
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I am trying to render a haml file in a javascript response like so:
I want use html5's new tag to play a wav file (currently only supported
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.