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
3a7a93d5
Commit
3a7a93d5
authored
Jun 15, 2012
by
Prem Sichanugrist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Readme to mention sexy migration
parent
77ee8a51
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
5 deletions
+54
-5
README.md
+54
-5
No files found.
README.md
View file @
3a7a93d5
...
...
@@ -94,15 +94,13 @@ In your model:
In your migrations:
class AddAvatarColumnsToUser < ActiveRecord::Migration
class AddAvatarColumnsToUser
s
< ActiveRecord::Migration
def self.up
change_table :users do |t|
t.has_attached_file :avatar
end
add_attachment :users, :avatar
end
def self.down
drop_attached_file
:users, :avatar
remove_attachment
:users, :avatar
end
end
...
...
@@ -207,6 +205,57 @@ Paperclip::Attachment.default_options[:fog_directory] = ""
Paperclip
::
Attachment
.
default_options
[
:fog_host
]
=
"http://localhost:3000"
}
```
Migrations
----------
Paperclip defines several migration methods which can be used to create necessary columns in your
model. There are two types of method:
### Table Definition
class AddAttachmentToUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.attachment :avatar
end
end
end
If you're using Rails 3.2 or newer, this method works in
`change`
method as well:
class AddAttachmentToUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.attachment :avatar
end
end
end
### Schema Definition
class AddAttachmentToUsers < ActiveRecord::Migration
def self.up
add_attachment :users, :avatar
end
def self.down
remove_attachment :users, :avatar
end
end
If you're using Rails 3.2 or newer, you only need
`add_attachment`
in your
`change`
method:
class AddAttachmentToUsers < ActiveRecord::Migration
def change
add_attachment :users, :avatar
end
end
### Vintage syntax
Vintage syntax (such as
`t.has_attached_file`
and
`drop_attaached_file`
) are still supported in
Paperclip 3.x, but you're advised to update those migration files to use this new syntax.
Storage
-------
...
...
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