Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Advanced Social Features in Ruby on Rails Uploading Files Attaching Files: Part 2

Can't mass-assign protected attributes: attachement

I can attach a file but after I click post it give this error:

Can't mass-assign protected attributes: attachement

Has anyone come across this yet?

2 Answers

Brandon Barrette
Brandon Barrette
20,485 Points

You have to add that to attr_accessible. So if you have an "asset" on the picture model, in picture.rb you need to add ":asset" to the attr_accessible.

class Picture < ActiveRecord::Base
  belongs_to :album
  belongs_to :user
  attr_accessible :caption, :description, :asset

Got it, thanks and thanks for the quick repoonse!