Welcome to the Treehouse Community
Looking to learn something new?
error for attaching files to statuses
i havnt really had any trouble until now, but I could use some help. I'm in the advanced RoR tutorials, trying to add files to the status updates. I've gone through the videos twice and still havnt caught my error.
when I try to attach a file I'm given this error...
Paperclip::Error in StatusesController#create Document model missing required attr_accessor for 'attachment_file_name'
my create documents migration looks like this...
class CreateDocuments < ActiveRecord::Migration def change create_table :documents do |t| t.integer :user_id t.timestamps end add_index :documents, :user_id add_attachment :documents, :attachment add_column :statuses, :document_id, :integer end end
for documents.rb I have this
class Document < ActiveRecord::Base attr_accessible :attachment has_attached_file :attachment end
and added the @status.build_document to my new method in status controller
this is the repository for any other information https://github.com/mitchcail/Chipper
Jason Seifer, have you come across this problem at all? or know how to fix it?
I had the same problem and it's the exact error Brandon Barrette mentions in his post https://teamtreehouse.com/forum/attaching-files-to-statuses.
However, unlike Brandon's post, your problem and my problem don't seem to be related to a mistype. It's possible I missed something, but we seem to have the same code.
I was able to fix the problem by adding the line
into my document model. Now, I feel like this is redundant since my document model already has
which, to me, the attachment file name would be an attribute of the attachment, rendering the code I added unnecessary.
In any case, I know it works, but may be "improper." If anyone has anything to add I'd love to hear it.
Hope that helps, Mitch!