Skip to content

Commit

Permalink
Changed Readme to use Rails-style designation for column size
Browse files Browse the repository at this point in the history
  • Loading branch information
Drew Blas committed Mar 13, 2012
1 parent c295bc4 commit 9748a2e
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions README.md
Expand Up @@ -26,15 +26,11 @@ To specify different column names for styles, use `:column` in the style definit

If you need to create the BLOB columns (remember you should only be using this with a legacy database!!) ...you can use migrations like this:

add_column :users, :avatar_file, :binary
add_column :users, :avatar_medium_file, :binary
add_column :users, :avatar_thumb_file, :binary
add_column :users, :avatar_file, :binary, :limit => 2.gigabytes
add_column :users, :avatar_medium_file, :binary, :limit => 1.gigabyte
add_column :users, :avatar_thumb_file, :binary, :limit => 200.megabytes

Note the "binary" migration will not work for the LONGBLOB type in MySQL for the file contents column. You may need to craft a SQL statement for your migration, depending on which database server you are using. Here's an example migration for MySQL:

execute 'ALTER TABLE users ADD COLUMN avatar_file LONGBLOB'
execute 'ALTER TABLE users ADD COLUMN avatar_medium_file LONGBLOB'
execute 'ALTER TABLE users ADD COLUMN avatar_thumb_file LONGBLOB'
Note the "limit" option (when used for MySQL) will create a BLOB of the appropriate size (up to 4.gigabytes will create a LONGBLOB).

To avoid performance problems loading all of the BLOB columns every time you access your ActiveRecord object, a class method is provided on your model called `select_without_file_columns_for`. This is set to a `:select` scope hash that will instruct `ActiveRecord::Base.find` to load all of the columns except the BLOB/file data columns.

Expand Down

0 comments on commit 9748a2e

Please sign in to comment.