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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:34:42+00:00 2026-05-22T03:34:42+00:00

Here is a create action: def create @folder = Folder.new(params[:folder]) @folder.user_id = current_user.id if

  • 0

Here is a create action:

def create
  @folder = Folder.new(params[:folder])
  @folder.user_id = current_user.id
  if @folder.name != "Folder Name" && @folder.save
      respond_to do |format|
          format.html { redirect_to messages_url(:target => params[:target], :search => params[:search]) }
          format.js
      end
  else
      flash[:notice] = "Error saving folder. Please try again."
      redirect_to messages_url(:target => params[:target], :search => params[:search])
  end
end

What I’m trying to accomplish is this: when the save is successful, return create.js.erb (this works).

When the save is not successful, redirect_to messages_url normally (i.e. with HTML).

When the latter happens, the redirect is happening using JS, then I get an error showing that the index action (of course) cannot find a JS template. How can I do this redirect in HTML?

  • 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-22T03:34:43+00:00Added an answer on May 22, 2026 at 3:34 am

    you need to response to format too when save is not successful and can use js helpers to redirect the page. The code could be like this

    if @folder.name != "Folder Name" && @folder.save
          respond_to do |format|
              format.html { redirect_to messages_url(:target => params[:target], :search => params[:search]) }
              format.js
          end
      else
          flash[:notice] = "Error saving folder. Please try again."
          respond_to do |format|
            format.html { redirect_to messages_url(:target => params[:target], :search => params[:search])}
            format.js {render(:update) { |page| page.redirect_to messages_url(:target => params[:target], :search => params[:search])}}
          end
      end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following controller action: def create @board = Board.new(params[:board]) respond_to do |format|
I am using git configuration mentioned here If I create a new tab and
Here is code on view in FeesController show action template: <div id=payers_controls> <%= link_to_remote('New
I'm trying to follow the grails tutorial here . When I create a new
I'm on Rails 2.3.5. In a typical user controller create action class UsersController def
Here's my problem: I have do create a menu/list of actions (which would be
There are instructions here to create a C# assembly using the SimMetrics library. The
I am creating a web application using zend, here I create an interface from
Here it is Create a thread in suspended state. hThrd1 = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)
My goal here is to create a very simple template language. At the moment,

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.