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
34c9b747
Commit
34c9b747
authored
Nov 05, 2014
by
Ahmad Sherif
Committed by
Jon Yurek
Dec 08, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add handling for S3 path option being a proc
parent
3398282e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletions
+21
-1
lib/paperclip/storage/s3.rb
+1
-1
spec/paperclip/storage/s3_spec.rb
+20
-0
No files found.
lib/paperclip/storage/s3.rb
View file @
34c9b747
...
@@ -158,7 +158,7 @@ module Paperclip
...
@@ -158,7 +158,7 @@ module Paperclip
end
end
unless
@options
[
:url
].
to_s
.
match
(
/\A:s3.*url\Z/
)
||
@options
[
:url
]
==
":asset_host"
unless
@options
[
:url
].
to_s
.
match
(
/\A:s3.*url\Z/
)
||
@options
[
:url
]
==
":asset_host"
@options
[
:path
]
=
@options
[
:path
]
.
gsub
(
/:url/
,
@options
[
:url
]).
gsub
(
/\A:rails_root\/public\/system/
,
''
)
@options
[
:path
]
=
path_option
.
gsub
(
/:url/
,
@options
[
:url
]).
gsub
(
/\A:rails_root\/public\/system/
,
''
)
@options
[
:url
]
=
":s3_path_url"
@options
[
:url
]
=
":s3_path_url"
end
end
@options
[
:url
]
=
@options
[
:url
].
inspect
if
@options
[
:url
].
is_a?
(
Symbol
)
@options
[
:url
]
=
@options
[
:url
].
inspect
if
@options
[
:url
].
is_a?
(
Symbol
)
...
...
spec/paperclip/storage/s3_spec.rb
View file @
34c9b747
...
@@ -1474,6 +1474,26 @@ describe Paperclip::Storage::S3 do
...
@@ -1474,6 +1474,26 @@ describe Paperclip::Storage::S3 do
end
end
end
end
context
"path is a proc"
do
before
do
rebuild_model
storage: :s3
,
path:
->
(
attachment
)
{
attachment
.
instance
.
attachment_path
}
@dummy
=
Dummy
.
new
@dummy
.
class_eval
do
def
attachment_path
'/some/dynamic/path'
end
end
@dummy
.
avatar
=
stringy_file
end
it
"returns a correct path"
do
assert_match
'/some/dynamic/path'
,
@dummy
.
avatar
.
path
end
end
private
private
def
rails_env
(
env
)
def
rails_env
(
env
)
...
...
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