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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:29:06+00:00 2026-06-02T05:29:06+00:00

I have 2 models. Member and Survey member.rb as follows Class Member < ActiveRecord::Base

  • 0

I have 2 models. Member and Survey

member.rb as follows

Class Member < ActiveRecord::Base
  has_one :survey, :dependent => :destroy
  accepts_nested_attributes_for :survey

  attr_accessible :fname,:lname, :address, :city, :state, :zip, :email, :phone, :phone_alt, :e_contact, :e_contact_phone, :physician, :physician_phone, :chiropractor, :chiropractor_phone, :password, :password_confirmation, :remember_me, :survey_attributes

end

survey.rb as follows

Class Survey < ActiveRecord::base
  belongs_to :member
end

however, whenever I try to create the member with the survey attributes I receive

ActiveModel::MassAssignmentSecurity::Error: Can’t mass-assign protected attributes: surveys

I am testing this via the console.

  • 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-02T05:29:07+00:00Added an answer on June 2, 2026 at 5:29 am

    With a has_one association the accessible call should read:

    attr_accessible :survey_attributes
    

    The params you’re posting need to be nested, like so:

    params = { :member => { :name => 'Jack', :survey_attributes => { :attribute => 'value' } } }
    

    In the form make sure that you’re building the nested relationship correctly, ie. you must use:

    = form_for @member do |f|
      ...
      = f.fields_for :survey do |s|
        ...
    

    If you have those things setup like so it should work. If this isn’t catching your error then please show a log of what you’re trying in the console and isn’t working.

    See #accepts_nested_attributes_for in the Rails API for more info.

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

Sidebar

Related Questions

If I have the following models setup: class Member < ActiveRecord::Base has_many :children end
I have two models: class Member < ActiveRecord::Base has_many :member_tags end and class MemberTag
I have 4 models, Message, Group, User, Membership class Group < ActiveRecord::Base has_many :memberships
I have five models and their respective tables are Member:id,fname,lname Student:id,member_id(foreign key references member
I have a model looking like this. class ProjectMembership(models.Model): member = models.ForeignKey(User, related_name='project_membership_member_set') Edit:
I have the following models, Member and Map, set up as so: class Member
I have a Rails app with the following (simplified) models: # member.rb class Member
I have the following Model: class Group(models.Model): member = models.ManyToManyField(Player, through='GroupMember') name = models.CharField(max_length=20,
I have two devise models: User and Member As such, I'm specifying authentication keys
I have models like this: class Vendor(models.Model): title = models.CharField() class Product(models.Model): ... vendor

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.