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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:52:22+00:00 2026-05-26T15:52:22+00:00

I have a jQuery post submitting a form to a controller create action, which

  • 0

I have a jQuery post submitting a form to a controller create action, which works great. If the save was successful I would like the create action to return a different form so the success callback will insert this form. Is this possible?

Here’s my code:

def create
    @event = Event.new(params[:event])

      if @event.save
        # This is where I would like to render a different controller action's view.
        render :controller => "shows", :action => "new", :layout => false
      else
        render action: "new"
      end
  end

For some reason it will not render the “shows/new” template. It keeps rendering the current controller’s new template without the layout. What am I missing here?

As an aside, I had a look at api.rubyonrails.org and tried to look up the render method. I found it listed as render(context,options), but can’t for the life of me find out what the valid options are. This seems to be a common pattern for a lot of methods. How do I find out? It will certainly help me figure out what my options are, and perhaps give various things a try.

Thanks,
Dany.

ADDED: I have now used render "shows/new", :layout => false in my controller action, which is working. In my new.html.erb for Shows I have declared <%= render "/shows/form" %>. Unfortunately I am now getting 500 error. I found this in development.log:

ActionView::Template::Error (undefined method `model_name' for NilClass:Class):
    1: <%= form_for(@show) do |f| %>
    2:   <% if @show.errors.any? %>
    3:     <div id="error_explanation">
    4:       <h2><%= pluralize(@show.errors.count, "error") %> prohibited this show from being saved:</h2>
  app/views/shows/_form.html.erb:1:in `_app_views_shows__form_html_erb___1397093944823648986_2158339140'
  app/views/shows/new.html.erb:3:in `_app_views_shows_new_html_erb__1152608637968596369_2158584080'
  app/controllers/events_controller.rb:61:in `create'

I’m not entirely sure what’s causing this…

  • 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-26T15:52:23+00:00Added an answer on May 26, 2026 at 3:52 pm

    Seems you missed: 2.2.3 Rendering an Action’s Template from Another Controller

    Try:

     render "shows/new", :layout => false
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

At the moment I have a jQuery do a POST to a Controller which
I have this conventional submit button which submit a form like this: <form method=post
I have written a form using the jQuery .post() function to post the data
I have a form that uses jQuery to submit an ajax post and it
I have an ASP.NET application in which i want to post data using jQuery
I have jQuery code which looks something like this on Button1 Click $('table.result_grid tbody
i have a form that i am submitting to my controller. I created a
I am submitting a form via jquery form submit. just like this example However,
So I have a form and I'm submitting the form through ajax using jquery
I have a form when submitted to a controller works fine, the controller signature

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.