31 July 2008

attr_accessible

If you use the new 'restful_authentication' plugin, you might have problems to update your User attributes:

WARNING: Can't mass-assign these protected attributes: uploaded_data, display_name, first_name, last_name

The solution is to add these attributes in your User model with attr_accessible:

# HACK HACK HACK -- how to do attr_accessible from here?
# prevents a user from submitting a crafted form that bypasses activation
# anything else you want your user to change should be added here.
attr_accessible :login, :email, :password, :password_confirmation,
:first_name,
:last_name,
:display_name,
:uploaded_data


attr_accessible specifies a white list of model attributes that can be set via# mass-assignment, such as update_attributes(attributes)

Thanks to this Frederick Cheung who explained it in the Rails mailing list.

1 comment:

Anonymous said...

Thanks for the info! This was driving me crazy.