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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:45:58+00:00 2026-05-24T01:45:58+00:00

I have the following test: it should respond with a json object do xhr

  • 0

I have the following test:

 it "should respond with a json object" do
            xhr :post, :create, :upload => @attr_upload, :format => :json
          end  

Here is my routes:

resources :uploads, :except =>[:new, :show]

I have a form that a user can upload images using the jquery-file-upload plugin:

<%= form_for @upload, :html => { :multipart => true } do |f| %>
<div class="fileupload-buttonbar">
    <label class="fileinput-button">
        <span>Add files... or drop them to upload</span>
            <%= f.file_field :photo, :id => "upload_photo" %>                
    </label>
</div>
<% end %>

In my controller I load the file and generate a json response:

def create
    @upload = Upload.new(params[:upload])
    respond_to do |format|
      if @upload.save
        set_current_upload(@upload)
        format.json {render :json => [ @upload.to_jq_upload ].to_json}
      else
        format.json {render :json => [ @upload.to_jq_upload.merge({ :error => "custom_failure" }) ].to_json}
      end
    end
  end

When I run my test I am getting the following:

No route matches {:action=>"update", :controller=>"uploads", :id=>#<Upload id: nil, created_at: nil, updated_at: nil, photo_file_name: nil, photo_content_type: nil, photo_file_size: nil, photo_updated_at: nil, uploadable_id: nil, uploadable_type: nil>}

Can anyone help me get this test working?
I am submitting to the create action so why is it trying to go to the update action?

Any help would be appreciated I have been working on this for two days.

  • 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-24T01:45:58+00:00Added an answer on May 24, 2026 at 1:45 am

    The request goes on update action, not create, so double check your templates with generated forms, their URLs

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

Sidebar

Related Questions

I have the following test that passes: test should create order do assert_difference('Order.count') do
I have the following test-code: CREATE TABLE #Foo (Foo int) INSERT INTO #Foo SELECT
I have the following routes in my app: GET /admin/comments(.:format) {:controller=>admin/comments, :action=>index} admin_comments POST
Hiho, I have the following test: test should annoy Chuck Norris do son =
I have following Rspec test: describe Productlimit do before(:each) do @productlimit = Factory.create(:productlimit, :user
I have the following code require 'test_helper' class ApplicationControllerTest < ActionController::TestCase test should display
I have the following controller action and test. I'm new to testing with Shoulda
I have following test class @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = {/services-test-config.xml}) public class MySericeTest { @Autowired
I have following databases: test table1 fields: id, password, name, lastname test2 table2 fields:
I have following string: Test, User < test@test.com >, Another, Test < another@test.com >,

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.