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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:34:20+00:00 2026-05-22T16:34:20+00:00

Updating the code formatting for better viewing. Folks, I have been looking at this

  • 0

Updating the code formatting for better viewing.

Folks,

I have been looking at this for sometime but I don’t understand what could be messing up here. I am using Devise.

class User < ActiveRecord::Base
  has_many :addresses
  accepts_nested_attributes_for :addresses

  # Other stuff here
end

class Address < ActiveRecord::Base

  belongs_to :user

  validates_presence_of :zip #:street_address1, 

end

——————– log output begin ——————————

Started POST “/users” for 127.0.0.1 at
2011-05-28 11:43:27 -0700 Processing
by RegistrationsController#create as
HTML Parameters: {“utf8″=>”√”,
“authenticity_token”=>”CEmdqlsmdYa6Jq0iIf5KAxxISsUCREIrFNXWkP80nhk=”,
“user”=>{“email”=>”a2@gmail.com”,
“password”=>”[FILT ERED]”,
“addresses_attributes”=>{“0″=>{“street_address1″=>”234
Pitkin Ct.”, “zip”=>”12456”}}},
“commit”=>”Sign up”} WARNING: Can’t
mass-assign protected attributes:
addresses_attributes SQL (0.0ms)
BEGIN SQL (164.0ms) SHOW TABLES
User Load (0.0ms) SELECT users.id
FROM users WHERE (users.email =
BINARY ‘a2@gmail.com’) LIMIT 1 SQL
(1.0ms) ROLLBACK

——————– log output end ——————————

The zip is present in the data posted and the posted data seems to be formatted properly. On the web page form I am getting the error that “Addresses zip can’t be blank”. I have dug around for what causes the “Can’t mass-assign protected attributes” warning but haven’t found anything that will help me.

Thanks for your thoughts and pointers.

-S

  • 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-22T16:34:21+00:00Added an answer on May 22, 2026 at 4:34 pm

    Have a look here and learn 🙂

    http://railscasts.com/episodes/26-hackers-love-mass-assignment


    Edit:

    Having accepts_nested_attributes_forin User model enables you to send the data to the Address model.

    Then, in the Address model, you have to set the requested attr_accessible

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

Sidebar

Related Questions

I'm a Drupal newbie plus I don't have much experience updating code, styles, and
I'm updating my code generator and have a choice between implementing a method stub
I have encountered a weird situation while updating/upgrading some legacy code. I have a
I have some code updating a dropdownlist, and then I fire the change event
i have written a java code for updating the element value with the following
I'm updating a VS6 MFC dialog application to VS2008. Updating the code has been
I am updating some code from the old mysql_* functions to PDO. It connects
I am updating the code on a daily basis and commit all changes in
I installed a windows service using installUtil.exe. After updating the code I used installUtil.exe
I'm updating some old code that has several POD structs that were getting zero'd

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.