From 21e68853fd7470eada2b970e58e5d8ed05098246 Mon Sep 17 00:00:00 2001 From: wangjohn Date: Thu, 29 Aug 2013 00:33:23 -0500 Subject: Small refactoring changes to generators. Made a method name clearer (added a bang to the end to show that it mutates arguments) and extracted indentation into its own method. --- railties/lib/rails/generators/rails/app/app_generator.rb | 4 ++-- .../rails/generators/rails/controller/controller_generator.rb | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index 041bfcb733..a336fd47f7 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -341,7 +341,7 @@ module Rails def handle_rails_rc! unless argv.delete("--no-rc") - insert_railsrc(railsrc) + insert_railsrc_into_argv!(railsrc) end end @@ -353,7 +353,7 @@ module Rails end end - def insert_railsrc(railsrc) + def insert_railsrc_into_argv!(railsrc) if File.exist?(railsrc) extra_args_string = File.read(railsrc) extra_args = extra_args_string.split(/\n+/).map {|l| l.split}.flatten diff --git a/railties/lib/rails/generators/rails/controller/controller_generator.rb b/railties/lib/rails/generators/rails/controller/controller_generator.rb index 822f35fb42..11dc598161 100644 --- a/railties/lib/rails/generators/rails/controller/controller_generator.rb +++ b/railties/lib/rails/generators/rails/controller/controller_generator.rb @@ -32,23 +32,27 @@ module Rails # namespace :foo do # namespace :bar do namespace_ladder = class_path.each_with_index.map do |ns, i| - %{#{" " * i * 2}namespace :#{ns} do\n } + %{#{indent(i)}namespace :#{ns} do\n } end.join # Create route # get "baz/index" - route = %{#{" " * depth * 2}get "#{file_name}/#{action}"\n} + route = %{#{indent(depth)}get "#{file_name}/#{action}"\n} # Create `end` ladder # end # end end_ladder = (1..depth).reverse_each.map do |i| - "#{" " * i * 2}end\n" + "#{indent(i)}end\n" end.join # Combine the 3 parts to generate complete route entry namespace_ladder + route + end_ladder end + + def indent(depth) + " " * depth * 2 + end end end end -- cgit v1.2.3 From 73b6095e13ef6be47fcabd65fcdd9c814bb9b375 Mon Sep 17 00:00:00 2001 From: Gaurish Sharma Date: Sun, 2 Jun 2013 18:24:07 +0530 Subject: Add notes about database connection pool [ci skip] --- .../generators/rails/app/templates/config/databases/postgresql.yml | 2 ++ 1 file changed, 2 insertions(+) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml b/railties/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml index eb569b7dab..0194dce6f3 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml +++ b/railties/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml @@ -55,6 +55,8 @@ production: adapter: postgresql encoding: unicode database: <%= app_name %>_production + # For details on connection pooling, see rails configration guide + # http://guides.rubyonrails.org/configuring.html#database-pooling pool: 5 username: <%= app_name %> password: -- cgit v1.2.3 From 5f98bb402b657f785e6bf1a49e83d44c6d3aa062 Mon Sep 17 00:00:00 2001 From: schneems Date: Tue, 18 Jun 2013 15:24:00 -0500 Subject: Only output Server logs in Development Right now when you start a server via `rails s`, the logger gets extended so that it logs to the file system and also to stdout. This extension behavior is not "intelligent" and if the default logger is already set to output to stdout, then the contents will be received twice. To capture logs in accordance with http://www.12factor.net/logs some platforms require the logs to be sent to standard out. If a logger is set to stdout, and the server is started using `rails server` instead of another method (i.e. `thin start` etc.) then the app will produce double logs. This PR fixes the issue by only extending the logger to standard out in the development environment. So that in production you don't get double logs like this: ``` ActionView::Template::Error (wrong number of arguments (5 for 4)): 1: <% lang_index = 0 %> 2:
3: