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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:07:52+00:00 2026-06-12T02:07:52+00:00

I am having troubles with an RSPec test. The test does a PUT with

  • 0

I am having troubles with an RSPec test. The test does a PUT with some objects in the request. The controller which receives the PUT seems to be not getting the correct values

For example, ‘put :update, :id => @channel.id, :channel => @channel, :tags => @tag’ Then, in the Controller, when I try to use params[:tags] there is an integer in that location. A Gist with the Spec and the controller method is at https://gist.github.com/3715021

This started happening when I upgraded from Rails 3.0.13 to 3.1.8

Any idea what might be happening here and how to resolve it?

  • 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-12T02:07:53+00:00Added an answer on June 12, 2026 at 2:07 am

    I’m assuming that @tag is an object from your Tags model. When you give Rails an object like

    `get :action, :foo => foo`
    

    or in a url helper (e.g., foo_path(foo)),

    Rails will turn your object into a parameter suitable for use in a url via the #to_param method. You’re probably getting an integer because Tag#to_param returns the id of the tag in your db.

    It looks like your update action, by contrast, expects params[:tags] to be a hash, presumably generated from a form that includes fields for values like tags[:name].

    I can’t help much more without knowing more about the relevant code. But I’m guessing what you want to do is change your test to read

    put :update, :id => @channel.id, :channel => @channel, :tags => { :name => 'tag' }
    

    or something like that, mimicking the params you’d get by actually submitting the form that PUTs to your update action.

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

Sidebar

Related Questions

I am having trouble parameterizing a shared_example in my rspec controller testing. My code
I'm having trouble with and RSpec view test. I'm using nested resources and the
im having troubles with parsing a feed and getting the time. i am using
I'm having trouble getting my rspec routing tests working with a subdomain constraint. Specifically
After adding the rspec test provided in Listing 7.32 rspec is having trouble returning
I'm using RSpec + Shoulda to test my RESTful controller in Rails 3. I'm
I'm having a bit of trouble with some RSpec tests on some of my
Currently having troubles getting results from a simple aggregate function with HQL. Here is
I'm having troubles with a script which sends HTTP headers to prevent page caching
I'm having trouble getting my test to pass. In my application, a User can

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.