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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:33:14+00:00 2026-05-22T03:33:14+00:00

each User can only have one MedicalHistory so I have class User < ActiveRecord::Base

  • 0

each User can only have one MedicalHistory so I have

class User < ActiveRecord::Base
    acts_as_authentic
end

class MedicalHistory < ActiveRecord::Base
    belongs_to :user
end

Using the above I can successfully create the user from the MedicalHistory model in the console:

newuser = Medicalhistory.new
newuser.user = User.new
newuser.user.username='testusername'
newuser.user.password='blahblah'
newuser.user.password_confirmation='blahblah'
newuser.user.save

MedicalHistory Side looks like following

#controller
def new
    @medicalhistory = MedicalHistory.new
    @medicalhistory.user = User.new
end

#form
<%=...%>
<%=f.intput :cell_phone%>
<%=f.fields_for :user do |builder|%>
  <%= render "registration_form", :f => builder %>
<% end %>

#Partial
<%=f.input :email%>
<%=f.input :password%>
<%=f.input :password_confirmation%>

Error

When submitting the form I am getting below error:

User(#-) expected, got ActiveSupport::HashWithIndifferentAccess(#)

Error is on following line:

#controller
def create
    @medicalhistory = Medicalhistory.new(session[:medicalhistory_params]) #gives error
    #somewhere here I should extract registration fields and register the user
end

Question
Is there a way I can avoid fields in the partial (registration fields) getting into the session[:medicalhistory_params]…is there a except or something?

  • 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-22T03:33:15+00:00Added an answer on May 22, 2026 at 3:33 am

    change your model as follows:

    class MedicalHistory < ActiveRecord::Base
      belongs_to :user
      accepts_nested_attributes_for :user
    end
    

    Ref here: http://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html

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

Sidebar

Related Questions

I have users, posts and comments. User can post only one comment to each
The idea here is that the user can only have one selection for an
Background Each Project has one Account it is associated with. Each User can have
I have a web application with users and their documents. Each user can have
I have an application where for each object the user can specify his own
i have a countries list. Each user can check multiple countries. Once saved, this
I'm building an app where each user can have multiple profiles. Users can upload
I have a development MySQL (InnoDB only) server with several users. Each user has
Case can have many Replies and one User, Replies can have one Case and
My Rails application makes use of Time.zone so that each user can set their

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.