Closed oldwolf closed 11 years ago
yeah, i'm guessing that's a result of the update to require whitelisting of attributes in the model.
If you have time to implement, i'd love a pull request. Otherwise i'll try to get to when I can.
thanks!
On Mon, Oct 22, 2012 at 8:41 PM, oldwolf notifications@github.com wrote:
I've got this error while I'm trying to create comment in console
p.comments.create(:title => 'First Comment', :comment => 'This is the first comment.') ActiveModel::MassAssignmentSecurity::Error: Can't mass-assign protected attributes: title, comment
but below command works
c = p.comments.create c.title = 'First Comment' c.comment = 'This is the first comment.' c.save => true
Probably we need to set attr_accessible in comment model, right?
— Reply to this email directly or view it on GitHubhttps://github.com/jackdempsey/acts_as_commentable/issues/26.
Not sure why this is close.
The ReadMe imply that commentable.comments.create(:title => "First comment.", :comment => "This is the first comment.")
is doable but in fact without adding attr_accessible :title, :comment
manually to the class it wont work.
S I guess, the solutions would be to either change the generator or change the ReadMe :)
yep, that would be great theonegri, if you'd like to update the README I'll happily accept the patch.
I updated the model instead, I think it makes more sense. https://github.com/jackdempsey/acts_as_commentable/pull/45
The problem is that master is designed to work with Rails 4, and this is a Rails 3 feature; that's why I suggested the README. Appreciate your efforts but I can't merge the model change in as a result.
My bad, I did not realized that. Her you are: https://github.com/theonegri/acts_as_commentable/commit/e9f06030a0cef2d97063ef1d2a5c7f4c46f530ac
I've got this error while I'm trying to create comment in console
but below command works
Probably we need to set attr_accessible in comment model, right? EDIT: Add attr_accessible :title, :comment into comment model solved the problem