Skip to content

Commit

Permalink
Disabled Classes-Preloading for production in order for dynamic attac…
Browse files Browse the repository at this point in the history
…hment options to work
  • Loading branch information
Qiushi (Billy) He authored and jamesu committed Nov 20, 2009
1 parent 146bac8 commit b2f894c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 22 deletions.
10 changes: 3 additions & 7 deletions app/models/company.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,18 @@ class Company < ActiveRecord::Base

has_and_belongs_to_many :projects, :join_table => :project_companies

LOGO_OPTIONS_BASIC = {
has_attached_file :logo, {
:styles => { :thumb => "50x50" },
:storage => AppConfig.attach_to_s3 ? :s3 : :filesystem,
:default_url => ''
}

LOGO_OPTIONS_S3 = {
}.merge(AppConfig.attach_to_s3 ? {
:s3_credentials => {
:access_key_id => AppConfig.s3_access_key,
:secret_access_key => AppConfig.s3_secret_key
},
:path => ":attachment/:id/:style.:extension",
:bucket => 'htc_company_logo'
}

has_attached_file :logo, LOGO_OPTIONS_BASIC.merge(AppConfig.attach_to_s3 ? LOGO_OPTIONS_S3 : {})
} : {})

before_create :process_params
before_update :process_update_params
Expand Down
10 changes: 3 additions & 7 deletions app/models/project_file_revision.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,18 @@ class ProjectFileRevision < ActiveRecord::Base
belongs_to :created_by, :class_name => 'User', :foreign_key => 'created_by_id'
belongs_to :updated_by, :class_name => 'User', :foreign_key => 'updated_by_id'

DATA_OPTIONS_BASIC = {
has_attached_file :data, {
:styles => { :thumb => "50x50" },
:storage => AppConfig.attach_to_s3 ? :s3 : :filesystem,
:default_url => ''
}

DATA_OPTIONS_S3 = {
}.merge(AppConfig.attach_to_s3 ? {
:s3_credentials => {
:access_key_id => AppConfig.s3_access_key,
:secret_access_key => AppConfig.s3_secret_key
},
:path => ":attachment/:id/:style.:extension",
:bucket => 'htc_project_file_revision_data'
}

has_attached_file :data, DATA_OPTIONS_BASIC.merge(AppConfig.attach_to_s3 ? DATA_OPTIONS_S3 : {})
} : {})

before_create :process_params
before_update :process_update_params
Expand Down
10 changes: 3 additions & 7 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,18 @@ class User < ActiveRecord::Base

has_and_belongs_to_many :subscriptions, :class_name => 'ProjectMessage', :association_foreign_key => 'message_id', :join_table => :message_subscriptions

AVATAR_OPTIONS_BASIC = {
has_attached_file :avatar, {
:styles => { :thumb => "50x50" },
:storage => AppConfig.attach_to_s3 ? :s3 : :filesystem,
:default_url => ''
}

AVATAR_OPTIONS_S3 = {
}.merge(AppConfig.attach_to_s3 ? {
:s3_credentials => {
:access_key_id => AppConfig.s3_access_key,
:secret_access_key => AppConfig.s3_secret_key
},
:path => ":attachment/:id/:style.:extension",
:bucket => 'htc_user_avatar'
}

has_attached_file :avatar, AVATAR_OPTIONS_BASIC.merge(AppConfig.attach_to_s3 ? AVATAR_OPTIONS_S3 : {})
} : {})

has_many :assigned_times, :class_name => 'ProjectTime', :foreign_key => 'assigned_to_user_id'

Expand Down
3 changes: 2 additions & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

# The production environment is meant for finished, "live" apps.
# Code is not reloaded between requests
config.cache_classes = true
# config.cache_classes = true
config.cache_classes = false

# Use a different logger for distributed setups
# config.logger = SyslogLogger.new
Expand Down

0 comments on commit b2f894c

Please sign in to comment.