Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Can't mass-assign protected attributes: parent_id #101

rschmitty opened this Issue · 2 comments

2 participants

Rick Schmitty John Rees
Rick Schmitty

When trying to save an object I get the following error

Can't mass-assign protected attributes: parent_id

In the form I've used code from the wiki

<%= f.label :parent_id %><br />
<%= f.collection_select :parent_id, @pages, :id, :name_for_selects, :include_blank => true %>

And in my create method I have

@page =[:page])

The debut post shows my form values

 "commit"=>"Create Page"}

I've followed the readme to include has_ancestry in my Page model. It also fails with the same error from console

Page.create! :title => 'Test', :parent => Page.create!(:title=>'Test Parent')

What am I missing?

John Rees

Have you got attr_accessible :parent_id in your Page model?

Rick Schmitty

Ah for some reason I thought that would be bad. Yes it works with that in attr accessible

Rick Schmitty rschmitty closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.