diff options
| author | Luc Donnet | 2015-01-05 14:56:12 +0100 |
|---|---|---|
| committer | Luc Donnet | 2015-01-05 14:56:12 +0100 |
| commit | 3bc6d313bebdc1f03e4021aabbc774a0cd97d938 (patch) | |
| tree | ac5b8c6d8309012136606d9fd9b9a00290f486a8 /config | |
| parent | e632a4634b1762f4c73d11f1e5b127de9832a1ff (diff) | |
| download | chouette-core-3bc6d313bebdc1f03e4021aabbc774a0cd97d938.tar.bz2 | |
Initialize rails 4 migration
Diffstat (limited to 'config')
| -rw-r--r-- | config/application.rb | 19 | ||||
| -rw-r--r-- | config/database.yml | 35 | ||||
| -rw-r--r-- | config/environments/development.rb | 21 | ||||
| -rw-r--r-- | config/environments/production.rb | 92 | ||||
| -rw-r--r-- | config/environments/test.rb | 11 | ||||
| -rw-r--r-- | config/initializers/active_enum.rb | 36 | ||||
| -rw-r--r-- | config/initializers/apartment.rb | 49 | ||||
| -rw-r--r-- | config/initializers/db_migrate_in_war.rb | 16 | ||||
| -rw-r--r-- | config/initializers/devise.rb | 2 | ||||
| -rw-r--r-- | config/initializers/postgresql_adapter_patch.rb | 24 | ||||
| -rw-r--r-- | config/initializers/squeel.rb | 18 | ||||
| -rw-r--r-- | config/routes.rb | 28 |
12 files changed, 210 insertions, 141 deletions
diff --git a/config/application.rb b/config/application.rb index d86b254f3..7c0a6c42a 100644 --- a/config/application.rb +++ b/config/application.rb @@ -2,14 +2,19 @@ require File.expand_path('../boot', __FILE__) ENV['RANSACK_FORM_BUILDER'] = '::SimpleForm::FormBuilder' -require 'rails/all' -if defined?(Bundler) - # If you precompile assets before deploying to production, use this line - Bundler.require(*Rails.groups(:assets => %w(development test))) - # If you want your assets lazily compiled in production, use this line - # Bundler.require(:default, :assets, Rails.env) -end +# Pick the frameworks you want: +require "active_model/railtie" +require "active_record/railtie" +require "action_controller/railtie" +require "action_mailer/railtie" +require "action_view/railtie" +require "sprockets/railtie" +# require "rails/test_unit/railtie" + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) module ChouetteIhm class Application < Rails::Application diff --git a/config/database.yml b/config/database.yml index 1685c484f..08d265760 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,35 +1,24 @@ -# SQLite version 3.x -# gem 'activerecord-jdbcsqlite3-adapter' -# -# Configure Using Gemfile -# gem 'activerecord-jdbcsqlite3-adapter' -# -development: - adapter: <%= RUBY_PLATFORM == "java" ? "jdbcpostgresql" : "postgresql" %> - database: chouette_dev - encoding: utf8 - host: localhost +default: &default + adapter: postgresql + encoding: unicode + pool: 5 port: 5432 + host: localhost + schema_search_path: "public" username: chouette password: chouette +development: + <<: *default + database: chouette_dev + # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: - adapter: <%= RUBY_PLATFORM == "java" ? "jdbcpostgresql" : "postgresql" %> + <<: *default database: chouette_test - encoding: utf8 - host: localhost - port: 5432 - username: chouette - password: chouette production: - adapter: <%= RUBY_PLATFORM == "java" ? "jdbcpostgresql" : "postgresql" %> + <<: *default database: chouette2 - encoding: utf8 - host: localhost - port: 5432 - username: chouette - password: chouette diff --git a/config/environments/development.rb b/config/environments/development.rb index 0d33ac03c..3000da9f2 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -23,22 +23,25 @@ ChouetteIhm::Application.configure do # Print deprecation notices to the Rails logger config.active_support.deprecation = :log - # Only use best-standards-support built into browsers - config.action_dispatch.best_standards_support = :builtin + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load - # Do not compress assets - config.assets.compress = false + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = false - # Expands the lines which load the assets - config.assets.debug = true + # Adds additional error checking when serving assets at runtime. + # Checks for improperly declared sprockets dependencies. + # Raises helpful error messages. + config.assets.raise_runtime_errors = true - config.active_record.mass_assignment_sanitizer = :strict + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true # uncomment to show chouette error view in development #config.consider_all_requests_local = false - config.active_record.auto_explain_threshold_in_seconds = (RUBY_PLATFORM == "java" ? nil : 0.5) - config.action_mailer.default_url_options = { :host => 'localhost:3000' } # replace this with your production tracker code diff --git a/config/environments/production.rb b/config/environments/production.rb index a320dc448..07aff1a84 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -4,76 +4,100 @@ ChouetteIhm::Application.configure do # Code is not reloaded between requests config.cache_classes = true - # Full error reports are disabled and caching is turned on + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. config.consider_all_requests_local = false config.action_controller.perform_caching = true - # Disable Rails's static asset server (Apache or nginx will already do this) - config.serve_static_assets = true + # Enable Rack::Cache to put a simple HTTP cache in front of your application + # Add `rack-cache` to your Gemfile before enabling this. + # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. + # config.action_dispatch.rack_cache = true + + # Disable Rails's static asset server (Apache or nginx will already do this). + config.serve_static_assets = false - # Compress JavaScripts and CSS - config.assets.compress = false + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass - # Don't fallback to assets pipeline if a precompiled asset is missed + # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = false # Generate digests for assets URLs config.assets.digest = true - # Defaults to Rails.root.join("public/assets") - # config.assets.manifest = YOUR_PATH - - # Specifies the header that your server uses for sending files + # Version of your assets, change this if you want to expire all your assets. + config.assets.version = '1.0' + + # Specifies the header that your server uses for sending files. # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true - # See everything in the log (default is :info) - #config.log_level = :info + # Set to :debug to see everything in the log. + config.log_level = :info - # Use a different logger for distributed setups - #if ENV['OS'] == 'Windows_NT' - # # args = log_path,number of files,file sizes - # config.logger = Logger.new("C:/chouette/logs/chouette2.log", 5, 10.megabytes) - #else - require 'syslog_logger' - config.logger = SyslogLogger.new("rails/chouette2").tap do |logger| - logger.level = Logger::INFO - end - #end + # Prepend all log lines with the following tags. + # config.log_tags = [ :subdomain, :uuid ] - # Use a different cache store in production + # Use a different logger for distributed setups. + # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + + # Use a different cache store in production. # config.cache_store = :mem_cache_store - # Enable serving of images, stylesheets, and JavaScripts from an asset server - # config.action_controller.asset_host = "chouette2" + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = "http://assets.example.com" - # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) + # Precompile additional assets. + # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. # config.assets.precompile += %w( search.js ) - # Disable delivery errors, bad email addresses will be ignored + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. # config.action_mailer.raise_delivery_errors = false - - # Enable threaded mode - # NOTICE : With Rails 3.2, Delayed::JRubyWorker blocks the application without threaded mode - # config.threadsafe! # Enable locale fallbacks for I18n (makes lookups for any locale fall back to - # the I18n.default_locale when a translation can not be found) + # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true - # Send deprecation notices to registered listeners + # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify + # Disable automatic flushing of the log to improve performance. + # config.autoflush_log = false + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false + + # Use a different logger for distributed setups + #if ENV['OS'] == 'Windows_NT' + # # args = log_path,number of files,file sizes + # config.logger = Logger.new("C:/chouette/logs/chouette2.log", 5, 10.megabytes) + #else + require 'syslog_logger' + config.logger = SyslogLogger.new("rails/chouette2").tap do |logger| + logger.level = Logger::INFO + end + #end + if ENV['CHOUETTE_BASE_URL'].nil? config.action_mailer.default_url_options = { :host => 'my-domain-name.com' } else config.action_mailer.default_url_options = { :host => ENV['CHOUETTE_BASE_URL'] } end - # Configure the e-mail address which will be shown in Devise::Maile if ENV['CHOUETTE_MAIL_SENDER'].nil? config.mailer_sender = "chouette-production@my-domain-name.com" diff --git a/config/environments/test.rb b/config/environments/test.rb index d5a5fe5e8..661865fd0 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -7,6 +7,11 @@ ChouetteIhm::Application.configure do # and recreated between test runs. Don't rely on the data there! config.cache_classes = true + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + # Configure static asset server for tests with Cache-Control for performance config.serve_static_assets = true config.static_cache_control = "public, max-age=3600" @@ -24,9 +29,6 @@ ChouetteIhm::Application.configure do # Disable request forgery protection in test environment config.action_controller.allow_forgery_protection = false -# Raise exception on mass assignment protection for Active Record models - config.active_record.mass_assignment_sanitizer = :strict - # Configure the e-mail address which will be shown in Devise::Maile config.mailer_sender = "appli@chouette.mobi" @@ -44,6 +46,9 @@ ChouetteIhm::Application.configure do # Print deprecation notices to the stderr config.active_support.deprecation = :stderr + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + # replace this with your production tracker code GA.tracker = "UA-AAAAAAAA" diff --git a/config/initializers/active_enum.rb b/config/initializers/active_enum.rb index cabf0bf7b..ae371bfa4 100644 --- a/config/initializers/active_enum.rb +++ b/config/initializers/active_enum.rb @@ -1,24 +1,24 @@ -# Form helper integration -# require 'active_enum/form_helpers/formtastic' # for Formtastic <2 -require 'active_enum/form_helpers/formtastic2' # for Formtastic 2.x +# # Form helper integration +# # require 'active_enum/form_helpers/formtastic' # for Formtastic <2 +# require 'active_enum/form_helpers/formtastic2' # for Formtastic 2.x -ActiveEnum.setup do |config| +# ActiveEnum.setup do |config| - # Extend classes to add enumerate method - # config.extend_classes = [ ActiveRecord::Base ] +# # Extend classes to add enumerate method +# # config.extend_classes = [ ActiveRecord::Base ] - # Return name string as value for attribute method - # config.use_name_as_value = false +# # Return name string as value for attribute method +# # config.use_name_as_value = false - # Storage of values (:memory, :i18n) - # config.storage = :memory +# # Storage of values (:memory, :i18n) +# # config.storage = :memory -end - -# ActiveEnum.define do -# -# enum(:enum_name) do -# value 1 => 'Name' -# end -# # end + +# # ActiveEnum.define do +# # +# # enum(:enum_name) do +# # value 1 => 'Name' +# # end +# # +# # end diff --git a/config/initializers/apartment.rb b/config/initializers/apartment.rb index 095ee9aff..03ae0ed0a 100644 --- a/config/initializers/apartment.rb +++ b/config/initializers/apartment.rb @@ -1,7 +1,48 @@ +# Require whichever elevator you're using below here... +# +# require 'apartment/elevators/generic' +# require 'apartment/elevators/domain' +# require 'apartment/elevators/subdomain' + +# +# Apartment Configuration +# Apartment.configure do |config| - # set your options (described below) here - config.excluded_models = ["Referential", "Organisation", "User", "ImportTask", "Export", "ExportLogMessage","ComplianceCheckTask", "ComplianceCheckResult", "Delayed::Backend::ActiveRecord::Job", "Api::V1::ApiKey", "RuleParameterSet"] # these models will not be multi-tenanted, but remain in the global (public) namespace - # Dynamically get database names to migrate - config.database_names = lambda{ Referential.pluck(:slug) } + # These models will not be multi-tenanted, + # but remain in the global (public) namespace + # + # An example might be a Customer or Tenant model that stores each tenant information + # ex: + # + # config.excluded_models = %w{Tenant} + # + config.excluded_models = ["Referential", "Organisation", "User", "ImportTask", "Export", "ExportLogMessage","ComplianceCheckTask", "ComplianceCheckResult", "Delayed::Backend::ActiveRecord::Job", "Api::V1::ApiKey", "RuleParameterSet"] + + # use postgres schemas? + config.use_schemas = true + + # use raw SQL dumps for creating postgres schemas? (only appies with use_schemas set to true) + #config.use_sql = true + + # configure persistent schemas (E.g. hstore ) + # config.persistent_schemas = %w{ hstore } + + # add the Rails environment to database names? + # config.prepend_environment = true + # config.append_environment = true + + # supply list of database names for migrations to run on + config.tenant_names = lambda{ Referential.pluck :slug } end + +## +# Elevator Configuration + +# Rails.application.config.middleware.use 'Apartment::Elevators::Generic', lambda { |request| +# # TODO: supply generic implementation +# } + +# Rails.application.config.middleware.use 'Apartment::Elevators::Domain' + +# Rails.application.config.middleware.use 'Apartment::Elevators::Subdomain' diff --git a/config/initializers/db_migrate_in_war.rb b/config/initializers/db_migrate_in_war.rb index ccba79773..662c512af 100644 --- a/config/initializers/db_migrate_in_war.rb +++ b/config/initializers/db_migrate_in_war.rb @@ -1,10 +1,10 @@ -Rails.configuration.after_initialize do - Rails.logger.info "Migrating database" - ActiveRecord::Migrator.migrate("db/migrate/", nil) +# Rails.configuration.after_initialize do +# Rails.logger.info "Migrating database" +# ActiveRecord::Migrator.migrate("db/migrate/", nil) - Apartment.database_names.each do |db| - Rails.logger.info "Migrating #{db} schema" - Apartment::Migrator.migrate db - end -end if ENV["CHOUETTE_RUN_MIGRATIONS"] == "true" +# Apartment.database_names.each do |db| +# Rails.logger.info "Migrating #{db} schema" +# Apartment::Migrator.migrate db +# end +# end if ENV["CHOUETTE_RUN_MIGRATIONS"] == "true" diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 8434a26c8..23cb26e8f 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -85,6 +85,8 @@ Devise.setup do |config| # a value less than 10 in other environments. config.stretches = Rails.env.test? ? 1 : 10 + config.secret_key = 'e9b20cea45078c982c9cd42cc64c484071d582a3d366ad2b51f676d168bccb2e0fd20e87ebe64aff57ad7f8a1a1c50b76cb9dc4039c287a195f9621fdb557993' + # Setup a pepper to generate the encrypted password. # config.pepper = "0420ef6a1b6b0ac63b9ac1e2b9624b411e331345a1bad99c85986f70aef62e9c7912955ea1616135224fc7c4ac319085a5e33831fb215a5e45043816746a2c2f" diff --git a/config/initializers/postgresql_adapter_patch.rb b/config/initializers/postgresql_adapter_patch.rb index 42968bbdf..ae228f62f 100644 --- a/config/initializers/postgresql_adapter_patch.rb +++ b/config/initializers/postgresql_adapter_patch.rb @@ -1,12 +1,12 @@ -module ::ArJdbc - module PostgreSQL - def quote_column_name(name) - if name.is_a?(Array) - name.collect { |n| %("#{n.to_s.gsub("\"", "\"\"")}") }.join(',') - else - %("#{name.to_s.gsub("\"", "\"\"")}") - end - end - end -end -ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::NATIVE_DATABASE_TYPES[:primary_key] = "bigserial primary key" +# module ::ArJdbc +# module PostgreSQL +# def quote_column_name(name) +# if name.is_a?(Array) +# name.collect { |n| %("#{n.to_s.gsub("\"", "\"\"")}") }.join(',') +# else +# %("#{name.to_s.gsub("\"", "\"\"")}") +# end +# end +# end +# end +# ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::NATIVE_DATABASE_TYPES[:primary_key] = "bigserial primary key" diff --git a/config/initializers/squeel.rb b/config/initializers/squeel.rb index aa3f2ff02..821e72952 100644 --- a/config/initializers/squeel.rb +++ b/config/initializers/squeel.rb @@ -1,12 +1,24 @@ Squeel.configure do |config| # To load hash extensions (to allow for AND (&), OR (|), and NOT (-) against - # hashes of conditions) + # hashes of conditions): + # config.load_core_extensions :hash # To load symbol extensions (for a subset of the old MetaWhere functionality, - # via ARel predicate methods on Symbols: :name.matches, etc) + # via Arel predicate methods on Symbols: :name.matches, etc): + # + # NOTE: Not recommended. Learn the new DSL. Use it. Love it. + # # config.load_core_extensions :symbol - # To load both hash and symbol extensions + # To load both hash and symbol extensions: + # # config.load_core_extensions :hash, :symbol + + # Alias an existing predicate to a new name. Use the non-grouped + # name -- the any/all variants will also be created. For example, + # to alias the standard "lt" predicate to "less_than", and gain + # "less_than_any" and "less_than_all" as well: + # + # config.alias_predicate :less_than, :lt end diff --git a/config/routes.rb b/config/routes.rb index 67eb757ae..c48feaa5b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,25 +7,13 @@ ChouetteIhm::Application.routes.draw do devise_scope :user do authenticated :user do - root :to => 'referentials#index' + root :to => 'referentials#index', as: :authenticated_root end - - unauthenticated do - root :to => 'devise/sessions#new' + unauthenticated :user do + root :to => 'devise/registrations#new', as: :unauthenticated_root end end - # Rails 4 syntax - # devise_for :users - # devise_scope :user do - # authenticated :user do - # root :to => 'referentials#index', as: :authenticated_root - # end - # unauthenticated :user do - # root :to => 'devise/registrations#new', as: :unauthenticated_root - # end - # end - namespace :api do namespace :v1 do @@ -62,7 +50,7 @@ ChouetteIhm::Application.routes.draw do resources :api_keys resources :rule_parameter_sets resources :autocomplete_stop_areas - match 'lines' => 'lines#destroy_all', :via => :delete + get 'lines' => 'lines#destroy_all', :via => :delete resources :group_of_lines do collection do get :name_filter @@ -166,10 +154,10 @@ ChouetteIhm::Application.routes.draw do end - match '/help/(*slug)' => 'help#show' + get '/help/(*slug)' => 'help#show' - match '/404', :to => 'errors#not_found' - match '/422', :to => 'errors#server_error' - match '/500', :to => 'errors#server_error' + get '/404', :to => 'errors#not_found' + get '/422', :to => 'errors#server_error' + get '/500', :to => 'errors#server_error' end |
