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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:39:03+00:00 2026-05-20T06:39:03+00:00

Below is a simplified view of my two models User and Patient. A User

  • 0

Below is a simplified view of my two models User and Patient.

A User has_one Patient and a Patient belongs_to a user.

What I am trying to do in the rails console is:

p = Patient.new(:user_id => 2, :user_attributes => [{:username => 'patient'},{:password => 'password'}])

I get the error:
NoMethodError: undefined method `with_indifferent_access’ for [{:username=>”patient”}, {:password=>”password”}]:Array

What am I doing wrong?

Below are the two models:

# == Schema Information
#
# Table name: users
#
#  id                 :integer         not null, primary key
#  username           :string(255)
#  encrypted_password :string(255)
#  salt               :string(255)
#  active             :boolean
#  disabled           :boolean
#  last_login         :time
#  first_name         :string(255)
#  last_name          :string(255)
#  address1           :string(255)
#  address2           :string(255)
#  city               :string(255)
#  state              :string(255)
#  postcode           :string(255)
#  phone              :string(255)
#  cell               :string(255)
#  email              :string(255)
#  created_at         :datetime
#  updated_at         :datetime
#
class User < ActiveRecord::Base
  has_one :patient

  attr_accessible :username, :password, :active, :disabled, :first_name, :last_name, 
  :address1, :address2, :city, :state, :postcode, :phone, :cell, :email
  attr_accessor :password

end

# == Schema Information
#
# Table name: patients
#
#  id         :integer         not null, primary key
#  user_id    :integer
#  created_at :datetime
#  updated_at :datetime
#

class Patient < ActiveRecord::Base
  belongs_to :user
  accepts_nested_attributes_for :user
  attr_accessible :user_id, :user_attributes
end
  • 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-20T06:39:03+00:00Added an answer on May 20, 2026 at 6:39 am

    Try this instead (removing the array brackets, and keeping everything within one set of hash curly braces):

    p = Patient.new(:user_id => 2, :user_attributes => {:username => 'patient' ,:password => 'password'})
    

    However, I’m not sure why you’re specifying a user_id and trying to create a new user too… maybe you just want this?

    p = Patient.new(:user_attributes => {:username => 'patient', :password => 'password'})
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Below is simplified example of what I am trying to achieve: class Product(models.Model): #
How can I optimize below SQL (simplified view of my complex query.) Ideally, I
The below code is very simplified. I'm trying to abstract a dispatcher context so
The code below is a simplified version of my website. On my site, the
I've simplified my JavaScript code to the example below; this code is giving me
I have below a working query that needs to be simplified. The reason is
I have a deeply nested for-comprehension, simplified to 3 levels below: x, y, and
I have a problem creating authentication part for my application. Below is the simplified
I'm trying to create an index on a view and it keeps failing, I'm
have a function, simplified below, that is exported from a BPL function DoA(amount: currency;

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.