I have set up paperclip to my app successfully and everything works except one thing. When I submit the form (the one with paperclip attachment) I get error saying: param is missing or the value is empty: user
and error is highlighting this part of my code:
params.require(:user).permit(:photo)
So, since I submit the form empty, rails things :photo is empty and it is right though. I did some research, people use this to make it work:
params.require(:user).permit(:photo) if params[:photo]
But, when I use if statement I get this error:
When assigning attributes, you must pass a hash as an argument.
and error highlights the if statement (first line) in this code:
if @profile.update_attributes(photo_parameter)
flash[:notice] = 'Your profile photo has been updated successfully'
redirect_to request.referer
else
Beside that, I also tried adding this to my model, but still doesn't work
validates_attachment_presence :photo
I am very confused. I thought you guys may have had the same problem. Because I am just simply trying show error message if there is no attachment submitted.
Thank you.