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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:33:07+00:00 2026-05-30T21:33:07+00:00

I have a CRUD application set up in Ruby on Rails 3 – its

  • 0

I have a CRUD application set up in Ruby on Rails 3 – its working as is. I need to add some ajax here. My first requirement is to retrieve a customised form when clicking on a New Form link. This is the link I have at this point:

<%= link_to 'New Book', new_book_path(:subject_id=>@subject.id), :remote=>true %>

For my controller I’ve made the following adjustment to the new book action:

def new
    @book = Book.new
    if params[:subject_id].to_i >0 then
      @book.subject_id = params[:subject_id]
    end

    if request.xhr?
      respond_to do |format|
        format.html # new.html.erb
        format.json { render json: @book }
        render :layout => false, :file=>'app/views/books/_form'
        return false
      end
    else
      respond_to do |format|
        format.html # new.html.erb
        format.json { render json: @book }
      end
    end
  end

I checked in firebug and clicking on the link generated returns the form html however I have no idea how to handle the response? Please do help.

  • 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-30T21:33:08+00:00Added an answer on May 30, 2026 at 9:33 pm

    Instead of responding with HTML respond with .js

    Inside your .js.erb file could be something like this

    $("#idname").append(<%= render "form" %>)
    

    That way it renders and returns the form HTML but also gives the js code to append the HTML.

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

Sidebar

Related Questions

I am working on my second CI application. I have created some simple CRUD
I have an Ajax-enabled CRUD application. If I display a record from my database
I have a Silverlight application that implements some basic CRUD operations on a fairly
I have a simple Crud application where there is one filed called Category. During
I have a web application that uses two databases. DB1 Users perform their CRUD
I have a fairly large CRUD winform app that is set up to display
I have a WCF service which performs CRUD operation on my data model: Add,
Here is my situation: I have two sets of tests for my android application.
I have a substanital WPF application set up as follows: Views, ViewModels, Business Objects
We have a server application that exposes a certain model, and set of services

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.