Commit 429c78ce by Henrik N

Add _updated_at. To be used for cache busting.

No tests yet since I had problems getting the suite to run :/
parent 311732b3
......@@ -19,12 +19,14 @@ In your migrations:
add_column :users, :avatar_file_name, :string
add_column :users, :avatar_content_type, :string
add_column :users, :avatar_file_size, :integer
add_column :users, :avatar_updated_at, :integer
end
def self.down
remove_column :users, :avatar_file_name
remove_column :users, :avatar_content_type
remove_column :users, :avatar_file_size
remove_column :users, :avatar_updated_at
end
end
......
......@@ -4,6 +4,7 @@ class <%= migration_name %> < ActiveRecord::Migration
add_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_file_name, :string
add_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_content_type, :string
add_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_file_size, :integer
add_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_updated_at, :datetime
<% end -%>
end
......@@ -12,6 +13,7 @@ class <%= migration_name %> < ActiveRecord::Migration
remove_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_file_name
remove_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_content_type
remove_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_file_size
remove_column :<%= class_name.underscore.camelize.tableize %>, :<%= attachment %>_updated_at
<% end -%>
end
end
......@@ -61,6 +61,7 @@ module Paperclip
@instance[:"#{@name}_file_name"] = uploaded_file.original_filename.strip.gsub /[^\w\d\.\-]+/, '_'
@instance[:"#{@name}_content_type"] = uploaded_file.content_type.strip
@instance[:"#{@name}_file_size"] = uploaded_file.size.to_i
@instance[:"#{@name}_updated_at"] = Time.now
@dirty = true
......@@ -230,6 +231,7 @@ module Paperclip
@instance[:"#{@name}_file_name"] = nil
@instance[:"#{@name}_content_type"] = nil
@instance[:"#{@name}_file_size"] = nil
@instance[:"#{@name}_updated_at"] = nil
end
def flush_errors #:nodoc:
......
......@@ -32,6 +32,7 @@ def rebuild_model options = {}
table.column :avatar_file_name, :string
table.column :avatar_content_type, :string
table.column :avatar_file_size, :integer
table.column :avatar_updated_at, :datetime
end
ActiveRecord::Base.send(:include, Paperclip)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment