You need to add photo
to your strong params:
def article_params
params.require(:article).permit(:title, :text, :photo)
end
Without it the value is not passed over to the model to be validated and saved.
I am assuming you already ran the migration to add Paperclip's photo_file_name
, photo_file_size
, photo_content_type
, photo_updated_at
fields to your articles
table.
Note: It is only necessary to include the attached file name photo
in the strong parameters; as long as this value reaches the model Paperclip will handle the rest.
In addition, you need to disable Paperclip's spoofing validation. It uses the OS file
command the determine the MIME type of the file but Windows doesn't have a file command so it always fails. You can disable the spoofing check by putting something like this in an initializer:
module Paperclip
class MediaTypeSpoofDetector
def spoofed?
false
end
end
end