Permalink
Browse files

Date.to_i has no extlib equivalent. added it

  • Loading branch information...
1 parent 8896bd4 commit 721fccc1fef0f22bfd99dee7176a49e4b4805911 @johnny committed Mar 5, 2012
Showing with 6 additions and 1 deletion.
  1. +6 −1 lib/dm-paperclip/attachment.rb
View
7 lib/dm-paperclip/attachment.rb
@@ -113,7 +113,7 @@ def assign uploaded_file
# update time appended to the url
def url style = default_style, include_updated_timestamp = true
the_url = original_filename.nil? ? interpolate(@default_url, style) : interpolate(@url, style)
- include_updated_timestamp && updated_at ? [the_url, updated_at.to_i].compact.join(the_url.include?("?") ? "&" : "?") : the_url
+ include_updated_timestamp && updated_at ? [the_url, seconds_since_unix_epoch(updated_at)].compact.join(the_url.include?("?") ? "&" : "?") : the_url
end
# Returns the path of the attachment as defined by the :path option. If the
@@ -411,5 +411,10 @@ def flush_errors #:nodoc:
[message].flatten.each {|m| instance.errors.add(name, m) }
end
end
+
+ def seconds_since_unix_epoch(date)
+ seconds_per_day = 86_400
+ ((date - ::DateTime.civil(1970)) * seconds_per_day).to_i
+ end
end
end

0 comments on commit 721fccc

Please sign in to comment.