Home paperclip resize not working for dynamic columns on attachment model
 I have a two columns on my attachment model on which the user sets the dimension to which they want to resize the image. However, the variables when the resize happens are nil, but set to actual values after the resize happens. below is the code  has_attached_file :file, :styles => lambda { |a| { :logo => ["200x50>",:png], :user_defined => ["#{a.instance.custom_width}x#{a.instance.custom_height}>",:png] } }  the custom_width & custom_height are nil when conversion happens however the logo conversion works as expected. I am using ruby 2.2.4p230 & Rails 4.2.4 below is the full mode code class Attachment < ActiveRecord::Base belongs_to :model_one belongs_to :attachable, polymorphic: true #has_attached_file :file, styles: { logo: ['200x50>',:png] } has_attached_file :file, styles: lambda { |attachment| attachment.instance.styles } def styles Rails.logger.info self.inspect Rails.logger.info self.attachable styles = {} m = "200x50>" l = "#{self.custom_width}x#{self.custom_height}>" styles[:logo] = [m, :png] styles[:user_defined] = [l, :png] styles end end  Can anyone please help and let me know if i am doing something wrong?