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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:48:19+00:00 2026-06-13T05:48:19+00:00

In my specs, when I run the POST request below, everything works fine. before

  • 0

In my specs, when I run the POST request below, everything works fine.

    before do
      request_payload = {
        player: {
          first_name: "Joe",
          last_name: "Carradine",
          team_id: "1"
        }
      }

      post :create, request_payload
    end

But when I run a spec for PUT:

    before do
      request_payload = {
        player: {
          first_name: "Buck",
          last_name: "Carradine",
          team_id: "1"
        }
      }

      put :update, { id: 3 }, request_payload
    end

I get an error like this:

 Failure/Error: put :update, { id: 1 }, request_payload
 NoMethodError:
   undefined method `[]' for nil:NilClass

I can’t figure out what is being considered nil. This API call works fine in a REST client.

This is another error based on a previous SO question: Receiving error in RSpec for PUT, but not POST

  • 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-06-13T05:48:20+00:00Added an answer on June 13, 2026 at 5:48 am

    You should do :

    put :update, { id: 3 }.merge(request_payload)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my specs, when I run the POST request below, everything works fine. before
http://ruby.railstutorial.org/chapters/static-pages#code:pages_controller_spec_title My code is as follows. When uncommented the test wont run. Below is
I am writing request specs ... I use Capybara... And I am in trouble
I cannot get request specs working when using Javascript. My specs pass if I
A git tool that meets the specs below is needed. Does one already exist?
I get the error in subj when I'm trying to run specs or generators
I've got strange issue - I hope someone run similar problem before. I'm trying
I setup Mongo and everything works great. When I use MongoVUE or the shell,
I recently wrote a node-based stack class, per instructions (specs in the comments before
I am trying to use rspec on my rails application I run spec path/to/spec/spec.rb

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.