This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
misc / cheatsheets / rails-2-config-cheatsheet.rb
| 4489edd6 » | aeden | 2008-08-28 | 1 | # Cheat sheet for Rails 2.x configuration elements | |
| 2 | # Created by: Anthony Eden (anthony.mp) | ||||
| 3 | # License: Attribution-Noncommercial-Share Alike 3.0 United States | ||||
| 4 | # License URL: http://creativecommons.org/licenses/by-nc-sa/3.0/us/ | ||||
| 5 | |||||
| 6 | # Rails Configuration elements and their default values | ||||
| 7 | config.root_path = begin | ||||
| 8 | raise 'RAILS_ROOT is not set' unless defined?(::RAILS_ROOT) | ||||
| 9 | raise 'RAILS_ROOT is not a directory' unless File.directory?(::RAILS_ROOT) | ||||
| 10 | |||||
| 11 | # Pathname is incompatible with Windows, but Windows doesn't have | ||||
| 12 | # real symlinks so File.expand_path is safe. | ||||
| 13 | if RUBY_PLATFORM =~ /(:?mswin|mingw)/ | ||||
| 14 | File.expand_path(::RAILS_ROOT) | ||||
| 15 | |||||
| 16 | # Otherwise use Pathname#realpath which respects symlinks. | ||||
| 17 | else | ||||
| 18 | Pathname.new(::RAILS_ROOT).realpath.to_s | ||||
| 19 | end | ||||
| 20 | end | ||||
| 21 | config.cache_classes = false | ||||
| 22 | config.controller_paths = begin | ||||
| 23 | paths = [File.join(root_path, 'app', 'controllers')] | ||||
| 24 | paths.concat builtin_directories | ||||
| 25 | paths | ||||
| 26 | end | ||||
| 27 | config.database_configuration_file = File.join(root_path, 'config', 'database.yml') | ||||
| 28 | config.routes_configuration_file = File.join(root_path, 'config', 'routes.rb') # new in 2.1 | ||||
| 29 | config.frameworks = ['active_record', 'action_controller', 'action_view', 'action_mailer', 'active_resource'] | ||||
| 30 | config.load_paths = begin | ||||
| 31 | paths = ["#{root_path}/test/mocks/#{environment}"] | ||||
| 32 | |||||
| 33 | # Add the app's controller directory | ||||
| 34 | paths.concat(Dir["#{root_path}/app/controllers/"]) | ||||
| 35 | |||||
| 36 | # Then components subdirectories. | ||||
| 37 | paths.concat(Dir["#{root_path}/components/[_a-z]*"]) | ||||
| 38 | |||||
| 39 | # Followed by the standard includes. | ||||
| 40 | paths.concat %w( | ||||
| 41 | app | ||||
| 42 | app/models | ||||
| 43 | app/controllers | ||||
| 44 | app/helpers | ||||
| 45 | app/services | ||||
| 46 | components | ||||
| 47 | config | ||||
| 48 | lib | ||||
| 49 | vendor | ||||
| 50 | ).map { |dir| "#{root_path}/#{dir}" }.select { |dir| File.directory?(dir) } | ||||
| 51 | |||||
| 52 | paths.concat builtin_directories | ||||
| 53 | end | ||||
| 54 | config.load_once_paths = [] | ||||
| 55 | config.log_level = environment == 'production' ? :info : :debug | ||||
| 56 | config.log_path = File.join(root_path, 'log', "#{environment}.log") | ||||
| 57 | config.logger = begin | ||||
| 58 | logger = ActiveSupport::BufferedLogger.new(configuration.log_path) | ||||
| 59 | logger.level = ActiveSupport::BufferedLogger.const_get(configuration.log_level.to_s.upcase) | ||||
| 60 | logger.auto_flushing = false if configuration.environment == "production" | ||||
| 61 | rescue StandardError =>e | ||||
| 62 | logger = ActiveSupport::BufferedLogger.new(STDERR) | ||||
| 63 | logger.level = ActiveSupport::BufferedLogger::WARN | ||||
| 64 | logger.warn( | ||||
| 65 | "Rails Error: Unable to access log file. Please ensure that #{configuration.log_path} exists and is chmod 0666. " + | ||||
| 66 | "The log level has been raised to WARN and the output directed to STDERR until the problem is fixed." | ||||
| 67 | ) | ||||
| 68 | end | ||||
| 69 | config.cache_store = begin # new in 2.1 | ||||
| 70 | if File.exist?("#{root_path}/tmp/cache/") | ||||
| 71 | [ :file_store, "#{root_path}/tmp/cache/" ] | ||||
| 72 | else | ||||
| 73 | :memory_store | ||||
| 74 | end | ||||
| 75 | end | ||||
| 76 | config.view_path = File.join(root_path, 'app', 'views') | ||||
| 77 | config.whiny_nils = false | ||||
| 78 | config.plugins = nil # Loads all plugins | ||||
| 79 | config.plugin_paths = ["#{root_path}/vendor/plugins"] | ||||
| 80 | config.plugin_locators = [Plugin::FileSystemLocator] | ||||
| 81 | config.plugin_loader = Plugin::Loader | ||||
| 82 | config.reload_plugins = true # new in 2.1 | ||||
| 83 | config.gems = [] # new in 2.1, use config.gem('gem_name', options) to add gems | ||||
| 84 | config.time_zone = nil # new in 2.1, use rake -D time to get tasks for determining time zones | ||||
| 85 | |||||
| 86 | # ActionController configuration elements | ||||
| 87 | config.action_controller.view_controller_internals = true # removed in 2.1 | ||||
| 88 | config.action_controller.protected_variables_cache = nil # removed in 2.1 | ||||
| 89 | config.action_controller.asset_host = '' | ||||
| 90 | config.action_controller.consider_all_requests_local = true | ||||
| 91 | config.action_controller.debug_routes = true | ||||
| 92 | config.action_controller.allow_concurrency = false | ||||
| 93 | config.action_controller.params_parsers = { | ||||
| 94 | Mime::MULTIPART_FORM => :multipart_form, | ||||
| 95 | Mime::URL_ENCODED_FORM => :url_encoded_form, | ||||
| 96 | Mime::XML => :xml_simple, | ||||
| 97 | Mime::JSON => :json # new in 2.1 | ||||
| 98 | } | ||||
| 99 | config.action_controller.default_charset = 'utf-8' | ||||
| 100 | config.action_controller.logger = config.logger | ||||
| 101 | config.action_controller.template_class = ActionView::Base # removed in 2.1 | ||||
| 102 | config.action_controller.ignore_missing_templates = nil # removed in 2.1 | ||||
| 103 | config.action_controller.resource_action_separator = '/' | ||||
| 104 | config.action_controller.request_forgery_protection_token = nil | ||||
| 105 | config.action_controller.optimise_named_routes = true | ||||
| 106 | config.action_controller.allow_forgery_protection = true | ||||
| 107 | |||||
| 108 | # ActionView configuration elements | ||||
| 109 | config.action_view.erb_trim_mode = '-' | ||||
| 110 | config.action_view.cache_template_loading = false | ||||
| 111 | config.action_view.cache_template_extensions = true # deprecated in 2.1 | ||||
| 112 | config.action_view.local_assigns_support_string_keys = true # removed in 2.1 | ||||
| 113 | config.action_view.debug_rjs = false | ||||
| 114 | config.action_view.erb_variable = '_erbout' | ||||
| 115 | config.action_view.computed_public_paths = {} | ||||
| 116 | config.action_view.logger = config.logger # delegated to action controller in 2.1 | ||||
| 117 | |||||
| 118 | # ActionMailer configuration elements | ||||
| 119 | config.action_mailer.logger = config.logger | ||||
| 120 | config.action_mailer.template_extensions = ['erb', 'builder', 'rhtml', 'rxml'] | ||||
| 121 | config.action_mailer.smtp_settings = { | ||||
| 122 | :address => "localhost", | ||||
| 123 | :port => 25, | ||||
| 124 | :domain => 'localhost.localdomain', | ||||
| 125 | :user_name => nil, | ||||
| 126 | :password => nil, | ||||
| 127 | :authentication => nil | ||||
| 128 | } | ||||
| 129 | config.action_mailer.sendmail_settings = { | ||||
| 130 | :location => '/usr/sbin/sendmail', | ||||
| 131 | :arguments => '-i -t' | ||||
| 132 | } | ||||
| 133 | config.action_mailer.raise_delivery_errors = true | ||||
| 134 | config.action_mailer.delivery_method = :smtp | ||||
| 135 | config.action_mailer.perform_deliveries = true | ||||
| 136 | config.action_mailer.deliveries = [] | ||||
| 137 | config.action_mailer.default_charset = 'utf-8' | ||||
| 138 | config.action_mailer.default_content_type = 'text/plain' | ||||
| 139 | config.action_mailer.default_mime_version = "1.0" | ||||
| 140 | config.action_mailer.default_implicit_parts_order = ["text/html", "text/enriched", "text/plain"] | ||||
| 141 | |||||
| 142 | # ActiveRecord configuration elements | ||||
| 143 | config.active_record.logger = config.logger | ||||
| 144 | config.active_record.configurations = {} | ||||
| 145 | config.active_record.primary_key_prefix_type = nil | ||||
| 146 | config.active_record.table_name_prefix = '' | ||||
| 147 | config.active_record.table_name_suffix = '' | ||||
| 148 | config.active_record.pluralize_table_names = true | ||||
| 149 | config.active_record.colorize_logging = true | ||||
| 150 | config.active_record.default_timezone = :local | ||||
| 151 | config.active_record.allow_concurrency = false | ||||
| 152 | config.active_record.schema_format = :ruby | ||||
| 153 | config.active_record.store_full_sti_class = false # new in 2.1 | ||||
| 154 | |||||
| 155 | # ActiveResource configuration elements | ||||
| 156 | config.active_resource.logger = config.logger | ||||







