Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Calculator

0

57
Views
How do you set paperclip expiry header for aws that depends on the object's date attribute

Im using gem 'paperclip', '~> 4.3', '>= 4.3.5', and gem 'aws-sdk', '< 2.0' and i want to set expiry header for the object im saving. I am doing smth like this and this is working:

 has_attached_file :image, styles: { medium: "340x280#", small:  "200x200#", xs: "200x140#", thumb: "80x80#", original: "400x380#"},
                          s3_headers:{ 'Cache-Control' => 'max-age=31557600', 'Expires' => 1.year.from_now.httpdate }

But now i want to do
'Expires' => Model.start_date + 1.month instead of 1.year.from_now But when i do it gives me undefined method error. I have also tried self.start_date and just start_date instead of Model.start_date, but the same error appears every time. I also tried to do

 def start_date_for_object
    return self.start_date + 1.month
 end

and then did: 'Expires' => start_date_for_object but same error! Why cant i call the model attribute in there?

Thank you for your advice.

8 months ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Sales
Legal
Terms and conditions Privacy policy
© 2023 PeakU Inc. All Rights Reserved.