Permalink
Browse files

Merge pull request #8 from drewblas/patch-1

Changed Readme to use Rails-style designation for column size
  • Loading branch information...
2 parents c295bc4 + 9748a2e commit 729848221b19c3791a35c80fe9803f4c1b6dd7d9 @patshaughnessy committed Mar 14, 2012
Showing with 4 additions and 8 deletions.
  1. +4 −8 README.md
View
@@ -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.

0 comments on commit 7298482

Please sign in to comment.