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
f82c0d94
Commit
f82c0d94
authored
Sep 15, 2010
by
Daniel Schierbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Further refactor the schema implementation
parent
f3eacd24
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
5 deletions
+10
-5
lib/paperclip/schema.rb
+10
-5
No files found.
lib/paperclip/schema.rb
View file @
f82c0d94
...
...
@@ -12,21 +12,26 @@ module Paperclip
:updated_at
=>
:datetime
}
def
has_attached_file
(
attachment_name
)
@@columns
.
each
do
|
name
,
type
|
column_name
=
full_column_name
(
attachment_name
,
name
)
column
(
column_name
,
type
)
with_columns_for
(
attachment_name
)
do
|
column_name
,
column_type
|
column
(
column_name
,
column_type
)
end
end
def
drop_attached_file
(
table_name
,
attachment_name
)
@@columns
.
each
do
|
name
,
type
|
column_name
=
full_column_name
(
attachment_name
,
name
)
with_columns_for
(
attachment_name
)
do
|
column_name
,
column_type
|
remove_column
(
table_name
,
column_name
)
end
end
protected
def
with_columns_for
(
attachment_name
)
@@columns
.
each
do
|
suffix
,
column_type
|
column_name
=
full_column_name
(
attachment_name
,
suffix
)
yield
column_name
,
column_type
end
end
def
full_column_name
(
attachment_name
,
column_name
)
"
#{
attachment_name
}
_
#{
column_name
}
"
.
to_sym
end
...
...
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