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
cf409665
Commit
cf409665
authored
Mar 23, 2016
by
Tute Costa
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2144 from thoughtbot/tc-remove-rails-3-snippets
Remove Rails 3 snippets
parents
16491494
70d490bb
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
1 additions
and
61 deletions
+1
-61
README.md
+0
-22
features/migration.feature
+0
-24
features/step_definitions/rails_steps.rb
+0
-6
lib/paperclip/schema.rb
+1
-6
spec/paperclip/attachment_spec.rb
+0
-3
No files found.
README.md
View file @
cf409665
...
...
@@ -189,18 +189,6 @@ Quick Start
### Models
**Rails 3**
```
ruby
class
User
<
ActiveRecord
::
Base
attr_accessible
:avatar
has_attached_file
:avatar
,
styles:
{
medium:
"300x300>"
,
thumb:
"100x100>"
},
default_url:
"/images/:style/missing.png"
validates_attachment_content_type
:avatar
,
content_type:
/\Aimage\/.*\Z/
end
```
**Rails 4**
```
ruby
class
User
<
ActiveRecord
::
Base
has_attached_file
:avatar
,
styles:
{
medium:
"300x300>"
,
thumb:
"100x100>"
},
default_url:
"/images/:style/missing.png"
...
...
@@ -241,16 +229,6 @@ end
### Controller
**Rails 3**
```
ruby
def
create
@user
=
User
.
create
(
params
[
:user
]
)
end
```
**Rails 4**
```
ruby
def
create
@user
=
User
.
create
(
user_params
)
...
...
features/migration.feature
View file @
cf409665
...
...
@@ -68,27 +68,3 @@ Feature: Migration
When
I rollback a migration
Then
I should not have attachment columns for
"avatar"
Scenario
:
Rails 3.2 change method
Given
I am using Rails newer than 3.1
When I write to "db/migrate/01_create_users.rb" with
:
"""
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users
end
end
"""
When I write to "db/migrate/02_add_attachment_to_users.rb" with
:
"""
class AddAttachmentToUsers < ActiveRecord::Migration
def change
add_attachment :users, :avatar
end
end
"""
And
I run a migration
Then
I should have attachment columns for
"avatar"
When
I rollback a migration
Then
I should not have attachment columns for
"avatar"
features/step_definitions/rails_steps.rb
View file @
cf409665
...
...
@@ -190,12 +190,6 @@ When /^I comment out the gem "([^"]*)" from the Gemfile$/ do |gemname|
comment_out_gem_in_gemfile
gemname
end
Given
/^I am using Rails newer than ([\d\.]+)$/
do
|
version
|
if
framework_version
<
version
pending
"Not supported in Rails <
#{
version
}
"
end
end
Given
(
/^I add a "(.*?)" processor in "(.*?)"$/
)
do
|
processor
,
directory
|
filename
=
"
#{
directory
}
/
#{
processor
}
.rb"
cd
(
"."
)
do
...
...
lib/paperclip/schema.rb
View file @
cf409665
...
...
@@ -12,10 +12,7 @@ module Paperclip
ActiveRecord
::
ConnectionAdapters
::
Table
.
send
:include
,
TableDefinition
ActiveRecord
::
ConnectionAdapters
::
TableDefinition
.
send
:include
,
TableDefinition
ActiveRecord
::
ConnectionAdapters
::
AbstractAdapter
.
send
:include
,
Statements
if
defined?
(
ActiveRecord
::
Migration
::
CommandRecorder
)
# Rails 3.1+
ActiveRecord
::
Migration
::
CommandRecorder
.
send
:include
,
CommandRecorder
end
ActiveRecord
::
Migration
::
CommandRecorder
.
send
:include
,
CommandRecorder
end
module
Statements
...
...
@@ -35,8 +32,6 @@ module Paperclip
def
remove_attachment
(
table_name
,
*
attachment_names
)
raise
ArgumentError
,
"Please specify attachment name in your remove_attachment call in your migration."
if
attachment_names
.
empty?
options
=
attachment_names
.
extract_options!
attachment_names
.
each
do
|
attachment_name
|
COLUMNS
.
keys
.
each
do
|
column_name
|
remove_column
(
table_name
,
"
#{
attachment_name
}
_
#{
column_name
}
"
)
...
...
spec/paperclip/attachment_spec.rb
View file @
cf409665
...
...
@@ -222,9 +222,6 @@ describe Paperclip::Attachment do
dummy
.
avatar_file_name
=
"fake.jpg"
dummy
.
stubs
(
:new_record?
).
returns
(
false
)
expected_string
=
'{"avatar":"/system/dummies/avatars/000/001/234/original/fake.jpg"}'
if
ActiveRecord
::
Base
.
include_root_in_json
# This is true by default in Rails 3, and false in 4
expected_string
=
%({"dummy":#{expected_string}})
end
# active_model pre-3.2 checks only by calling any? on it, thus it doesn't work if it is empty
assert_equal
expected_string
,
dummy
.
to_json
(
only:
[
:dummy_key_for_old_active_model
],
methods:
[
:avatar
])
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