Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
paperclip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
paperclip
Commits
429c78ce
Commit
429c78ce
authored
Jul 02, 2008
by
Henrik N
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add _updated_at. To be used for cache busting.
No tests yet since I had problems getting the suite to run :/
parent
311732b3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
0 deletions
+7
-0
README.rdoc
+2
-0
generators/paperclip/templates/paperclip_migration.rb
+2
-0
lib/paperclip/attachment.rb
+2
-0
test/helper.rb
+1
-0
No files found.
README.rdoc
View file @
429c78ce
...
...
@@ -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
...
...
generators/paperclip/templates/paperclip_migration.rb
View file @
429c78ce
...
...
@@ -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
lib/paperclip/attachment.rb
View file @
429c78ce
...
...
@@ -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:
...
...
test/helper.rb
View file @
429c78ce
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment