I want to compute a hash before uploading a file so that no duplicates are stored on the server.
Using the paperclip gem, what’s the best approach to do processing on a file before saving it or inserting data in the database?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
ActiveModel has a callback
before_create(among others) which would make an ideal place for you compute something before the record is created. For a full list of the callbacks available, see the Ruby on Rails Guides: Active Record Validations and Callbacks.