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?