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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:24:59+00:00 2026-06-18T12:24:59+00:00

I have a users_controller_spec.rb with this: describe POST create do describe with valid params

  • 0

I have a users_controller_spec.rb with this:

describe "POST create" do
  describe "with valid params" do
    let(:user) { create(:user) }

    it "assigns a newly created user as @user" do
      post :create, user: user
      assigns(:user).should be_a(User)
      assigns(:user).should be_persisted
    end
  end

 ...

end

Debuggin I found that the controller receive the next params

(rdb:1) pp params
{"user"=>"1", "controller"=>"users", "action"=>"create"}

Why “user” => “1” ?, why is not passing the user object properly ?

  • 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-18T12:25:00+00:00Added an answer on June 18, 2026 at 12:25 pm

    post :create expects attributes for the user model that it will use to create a user record. you are seeing “user” => “1” because it is passing in the id of the user you created into the :user parameter.

    You dont want to create a user record to test the create action. You want to create a hash of attributes for the create action to create the record.

    You could write something like this (assuming this would pass your model validations):

    user_attributes = { :email => "something@example.com", :username => "something" }
    post :create, user: user_attributes
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello everybody, I have this problem (title of the post). Failure/Error: get :create, :user
I have an object that I save like this in my controller: @user =
My create user method in the users_controller.rb looks like: def process_login is_login_valid(params[:user][:user_name], params[:user][:password]) if
I have a users controller. For a specific user I want to have something
I have controller users . In this controller I have action account which is
I have this simple code in my user_controller.rb file #listing all users def index
I currently have this as a search: <%= form_tag users_path, :controller => 'users', :action
I have a controller user with a method login For some reason, when I
After searching on this forum, I have found I'm at a standstill on this
According to this from the devise wiki I should be able to use a

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.