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

Attaching Files - Part 2 - Advanced Social Features in Ruby on Rails

Good day all, Has anybody come across the following error after following all the instructions for attaching files?

Paperclip::Errors::MissingRequiredValidatorError in StatusesController#create

I am under the impression that some additional code may be necessary in order to have the attachment validated.

These are the video instructions that I have followed:

http://teamtreehouse.com/library/advanced-social-features-in-ruby-on-rails/uploading-files/attaching-files-part-1

http://teamtreehouse.com/library/advanced-social-features-in-ruby-on-rails/uploading-files/attaching-files-part-2

Best Regards.

Giuseppe Brandi

4 Answers

Okay, found a solution. The new version of paperclip requires validating, as show on https://github.com/thoughtbot/paperclip

Basically, add validates_attachment_content_type :attachment, :content_type => /\Aimage\/.*\Z/ to the document model underneath the has_attached_file.

finally passed through the attribs for me.

Good day Drew,

I have followed your previous instructions and it worked - Thank You Very Much!

I got stucked again with the same sort of error message at adding avatars.

I have been able to solve the problem by changing the paperclip version to paperclip (3.4.1) and cocaine to cocaine (~> 0.5.0) in the gemfile.lock.

Please let me know if it works for you too.

I have the same issue, are you using rails 4 or 3?

Having a ton of problems trying to figure out how to white list the attributes properly with strong parameters, finally got it where I thought it would work and ran into your error.

Good day Drew, Thanks for your reply. I will try your solution as soon as I have the chance. I am using rails 4 and I have to confess that I think some of Jason's videos need to be updated. However, I guess that this kind of challenges are part of Web Developer's life. Have you have already started the Build a ToDo List Application with Rails 4? I started it yesterday i and I run into the following error: ExecJS::RuntimeError in ToDo List (this is the sort of message). I thought I could have done something wrong and I decided to upload Jason's files after running all the procedures as instructed by the videos. Guess what? Same problem! I went around by using the suggestions of this site: https://coderwall.com/p/bylmmw . Not sure if it was relevant but I had to cut off a file extension coffeescript (I cannot remember the file's name but you cannot go wrong as there is only one in the project). It worked!!