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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:35:56+00:00 2026-05-26T19:35:56+00:00

In my Rails app, I’m trying to use jQuery ajax to create a new

  • 0

In my Rails app, I’m trying to use jQuery ajax to create a new item via the default create method in my controller.

My routes.rb looks like this:

resources :items

The server side code is still as it was generated:

  # POST /items
  # POST /items.json
  def create
    @item = Item.new(params[:item])

    respond_to do |format|
      if @item.save
        format.html { redirect_to @item, :notice => 'Item was successfully created.' }
        format.json { render :json => @item, :status => :created, :location => @item }
      else
        format.html { render :action => "new" }
        format.json { render :json => @item.errors, :status => :unprocessable_entity }
      end
    end
  end

And my JavaScript:

$("#capture_input").focusout(function() { 
    var description = $(this).val(); 

    $.ajax({
      type: "POST",
      url: '/items/create.json',
      data: { 
        item: { 
          description : description
        } 
      },
      dataType: 'json',
      success: function(msg) {
        alert( "Data Saved: " + msg );
      }
    });
  });

This seems really straightforward, but I’m getting the following error:

ActionController::RoutingError (No route matches [POST] "/items/create.json"):

I’ve been able to use the default update method in a similar situation without any issues. What’s the problem here?

EDIT: Fixed typo in routes.rb code.

  • 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-26T19:35:57+00:00Added an answer on May 26, 2026 at 7:35 pm

    The example lines in your controller give a clue here.

    # POST /items
    # POST /items.json
    def create
    ...
    

    The create action is simply a POST to /items.json, so you just need to change the URL you are using in your jQuery to ‘/items.json’.

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

Sidebar

Related Questions

My Rails app uses the jquery.post() method to send some data from a clickable
I have a Rails app with the usual application_controller, and a controller (and model)
Rails app, learning CoffeeScript and Backbone.js: Uncaught TypeError: Cannot use 'in' operator to search
My Rails app is generating this error whenever validation aren't met: undefined method `model_name'
I'm deploying a Rails app on Heroku (for now) via git, and would also
Simple rails app using Postgres DB, getting 'integer out of range' error when trying
In my rails app, i have a create button as such def create @client
Needs to create a Rails App where I want to get the time in
I have a rails app doing facebook invite. I use javascript code for that
In my rails app I use the validation helpers in my active record objects

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.