Skip to content
This repository was archived by the owner on Aug 17, 2017. It is now read-only.
This repository was archived by the owner on Aug 17, 2017. It is now read-only.

MassAssignment protection still applies to associations named 'type' #81

Open
@josephlord

Description

@josephlord

I'm not sure if this is a Rails issue (and whether it will apply to Rails 4) or properly belongs here.

I have a Project model and a ProjectType model. Projects belong_to ProjectTypes. The foreign key (and the attribute) is named project_type_id but I had named the association as 'type' so that I could refer to project.type which seemed natural. This (seemed to) work while using attr_accessible but when I changed the Project model over to use strong_parameters I got MassAssignmentSecurity::Error as "id" and "type" appear to be protected by default.

It may have been foolish to use 'type' as an association name but no useful errors were reported and finding documentation to this effect isn't easy either.

For my purposes this is no longer an important issue as I have renamed the association but I thought by raising the issue here at the very least it could provide documentation for any others looking to understand why MassAssignmentSecurity::Error are occuring with all attr_protected/attr_accessible removed from the project and "config.active_record.whitelist_attributes = false" set in application.rb.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions