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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:19:28+00:00 2026-05-26T01:19:28+00:00

I am developing a rails application in which I have two models User and

  • 0

I am developing a rails application in which I have two models User and Client.
User is backed by devise and is responsible for authentication and has_one Client which holds the client details for a given user. This relation is always present as I ensure that a Client model is created whenever I create a User.

For the administration area I am using ActiveAdmin. Now, when I try to create a User through the administration interface I use a form like this:

form do |f|
  f.inputs :username, :email, :password
  f.inputs :name => "Client", :for => :client do |client|
    client.inputs :name, :address, ...
  end
end

The problem is that either the User nor the Client are saved and the page is reloaded with validation errors. I have checked rails console and there’s a WARNING: Can't mass-assign protected attributes: client_attributes message every time I try to create a User.

I have searched over this issue and found that in order to allow for mass-assignment one had to define attr_accessible for each of the fields allowed for the assignment. So, I had put this directive in Client model for each of the fields mentioned above and the message keeps appearing, preventing the models to be properly saved.

Does anyone have a clue on this?

  • 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-26T01:19:28+00:00Added an answer on May 26, 2026 at 1:19 am

    The problem is not in your Client model, but in your User model – because this is the primary model you are trying to create. All you need to do is to add client_attributes to the list of attr_accessible attributes in your User model, just as the error message in the log files says, e.g.:

    class User < ActiveRecord::Base
      attr_accessible :client_attributes
    end
    

    I imagine you already have a list of accessible attributes in the User class. So just add client_attributes to the end of that list.

    The changes you made to your Client model (i.e. adding a list of attributes to attr_accessible) is not needed for this to work. If you want, you can also go ahead and undo that.

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

Sidebar

Related Questions

I'm developing Rails application and I have to use authentication. I installed devise gem
I have a Ruby on Rails application that I'm developing on my computer, which
I'm developing a Rails 3 application that has two user types: Teacher and Company.
I'm developing a Rails 3 application that has two user types: Teacher and Company.
I'm developing a new rails application which is supposed to be installed several times
I'm developing a Ruby on Rails application that needs to allow the user to
I am developing a Rails application which will need frequent access to public APIs,
I am developing Ruby on Rails application which uses Thinking Sphinx. Unfortunately, from time
I am developing a Rails 3 application (which acts as an API) and I
I am developing a Rails 3 application from which I want to be able

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.