File: lib/generators/instance/templates/instance_environment.rb

Code

Code

   1  # Be sure to restart your server when you modify this file
   2 
   3  # Uncomment below to force Rails into production mode when
   4  # you don't control web/app server and can't set it the proper way
   5  # ENV['RAILS_ENV'] ||= 'production'
   6 
   7  # Specifies gem version of Rails to use when vendor/rails is not present
   8  require File.join(File.dirname(__FILE__), 'boot')
   9 
  10  require 'radius'
  11 
  12  Radiant::Initializer.run do |config|
  13    # Skip frameworks you're not going to use (only works if using vendor/rails).
  14    # To use Rails without a database, you must remove the Active Record framework
  15    # config.frameworks -= [ :action_mailer ]
  16 
  17    # Only load the extensions named here, in the order given. By default all
  18    # extensions in vendor/extensions are loaded, in alphabetical order. :all
  19    # can be used as a placeholder for all extensions not explicitly named.
  20    # config.extensions = [ :all ]
  21    
  22    # Unload the extensions named here.
  23    # config.ignore_extensions []
  24 
  25    # Your secret key for verifying cookie session data integrity.
  26    # If you change this key, all old sessions will become invalid!
  27    # Make sure the secret is at least 30 characters and all random,
  28    # no regular words or you'll be exposed to dictionary attacks.
  29    config.action_controller.session = {
  30      :key => '_<%= app_name %>_session',
  31      :secret      => <% require 'digest/sha1' %>'<%= Digest::SHA1.hexdigest("--#{app_name}--#{Time.now.to_s}--#{rand(10000000)}--") %>'
  32    }
  33 
  34    # Comment out this line if you want to turn off all caching, or
  35    # add options to modify the behavior. In the majority of deployment
  36    # scenarios it is desirable to leave Radiant's cache enabled and in
  37    # the default configuration.
  38    #
  39    # Additional options:
  40    #  :use_x_sendfile => true
  41    #    Turns on X-Sendfile support for Apache with mod_xsendfile or lighttpd.
  42    #  :use_x_accel_redirect => '/some/virtual/path'
  43    #    Turns on X-Accel-Redirect support for nginx. You have to provide
  44    #    a path that corresponds to a virtual location in your webserver
  45    #    configuration.
  46    #  :entitystore => "radiant:tmp/cache/entity"
  47    #    Sets the entity store type (preceding the colon) and storage
  48    #   location (following the colon, relative to Rails.root).
  49    #    We recommend you use radiant: since this will enable manual expiration.
  50    #  :metastore => "radiant:tmp/cache/meta"
  51    #    Sets the meta store type and storage location.  We recommend you use
  52    #    radiant: since this will enable manual expiration and acceleration headers.
  53    config.middleware.use ::Radiant::Cache
  54 
  55    # Use the database for sessions instead of the cookie-based default,
  56    # which shouldn't be used to store highly confidential information
  57    # (create the session table with 'rake db:sessions:create')
  58    config.action_controller.session_store = :cookie_store
  59 
  60    # Activate observers that should always be running
  61    config.active_record.observers = :user_action_observer
  62 
  63    # Make Active Record use UTC-base instead of local time
  64    config.time_zone = 'UTC'
  65 
  66    # Set the default field error proc
  67    config.action_view.field_error_proc = Proc.new do |html, instance|
  68      if html !~ /label/
  69        %{<span class="error-with-field">#{html} <span class="error">#{[instance.error_message].flatten.first}</span></span>}
  70      else
  71        html
  72      end
  73    end
  74 
  75    config.after_initialize do
  76      # Add new inflection rules using the following format:
  77      ActiveSupport::Inflector.inflections do |inflect|
  78        inflect.uncountable 'config'
  79      end
  80    end
  81  end