From 7f4171da5e3ed5b3e038b95f8f5ae05ba6e21bef Mon Sep 17 00:00:00 2001 From: John Barnette Date: Fri, 25 Apr 2008 22:34:39 -0700 Subject: Be friendlier when upgrading apps with an old boot.rb. If Rails doesn't respond to vendor_rails?, abort with an error asking the user to run 'rake rails:update'. Signed-Off-By: Michael Koziarski --- railties/lib/initializer.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'railties/lib') diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index b5bf9266f5..e36f917b15 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -160,6 +160,10 @@ module Rails # ActiveResource. This allows Gem plugins to depend on Rails even when # the Gem version of Rails shouldn't be loaded. def install_gem_spec_stubs + unless Rails.respond_to?(:vendor_rails?) + abort "Your config/boot.rb is outdated: Run 'rake rails:update'." + end + if Rails.vendor_rails? begin; require "rubygems"; rescue LoadError; return; end -- cgit v1.2.3 From 90f6062f7d5893f11ef186e80a91269421dc6f65 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Mon, 28 Apr 2008 11:59:55 -0700 Subject: run prepare callbacks after after_initialize blocks so config.to_prepare actually works --- railties/lib/initializer.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index e36f917b15..ea61d4e4fe 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -135,12 +135,12 @@ module Rails load_application_initializers - # Prepare dispatcher callbacks and run 'prepare' callbacks - prepare_dispatcher - # the framework is now fully initialized after_initialize + # Prepare dispatcher callbacks and run 'prepare' callbacks + prepare_dispatcher + # Routing must be initialized after plugins to allow the former to extend the routes initialize_routing -- cgit v1.2.3 From 1282ddaadcfc361f55fa0d5661d9d0036bd571c1 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 29 Apr 2008 17:23:50 -0500 Subject: Fixed tabs to spaces [#47 state:resolved] --- .../generators/components/scaffold/templates/view_edit.html.erb | 4 ++-- .../generators/components/scaffold/templates/view_new.html.erb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/rails_generator/generators/components/scaffold/templates/view_edit.html.erb b/railties/lib/rails_generator/generators/components/scaffold/templates/view_edit.html.erb index 35eae462c6..e289975596 100644 --- a/railties/lib/rails_generator/generators/components/scaffold/templates/view_edit.html.erb +++ b/railties/lib/rails_generator/generators/components/scaffold/templates/view_edit.html.erb @@ -5,7 +5,7 @@ <% for attribute in attributes -%>

- <%%= f.label :<%= attribute.name %> %>
+ <%%= f.label :<%= attribute.name %> %>
<%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>

<% end -%> @@ -15,4 +15,4 @@ <%% end %> <%%= link_to 'Show', @<%= singular_name %> %> | -<%%= link_to 'Back', <%= plural_name %>_path %> \ No newline at end of file +<%%= link_to 'Back', <%= plural_name %>_path %> diff --git a/railties/lib/rails_generator/generators/components/scaffold/templates/view_new.html.erb b/railties/lib/rails_generator/generators/components/scaffold/templates/view_new.html.erb index bc1f08abef..c47e8117b4 100644 --- a/railties/lib/rails_generator/generators/components/scaffold/templates/view_new.html.erb +++ b/railties/lib/rails_generator/generators/components/scaffold/templates/view_new.html.erb @@ -5,7 +5,7 @@ <% for attribute in attributes -%>

- <%%= f.label :<%= attribute.name %> %>
+ <%%= f.label :<%= attribute.name %> %>
<%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>

<% end -%> @@ -14,4 +14,4 @@

<%% end %> -<%%= link_to 'Back', <%= plural_name %>_path %> \ No newline at end of file +<%%= link_to 'Back', <%= plural_name %>_path %> -- cgit v1.2.3 From 1f2a4b37accc023c96148d54d8daa3a751446c44 Mon Sep 17 00:00:00 2001 From: "Hongli Lai (Phusion" Date: Thu, 1 May 2008 20:47:09 +0200 Subject: Prevent AssetTagHelper from crashing if RAILS_ROOT is not defined. Fixes compatibility with Passenger. [#84 state:resolved] Signed-off-by: Jeremy Kemper --- railties/lib/initializer.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index ea61d4e4fe..09a98d5aa3 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -28,7 +28,11 @@ module Rails end def root - RAILS_ROOT + if defined?(RAILS_ROOT) + RAILS_ROOT + else + nil + end end def env @@ -40,7 +44,7 @@ module Rails end def public_path - @@public_path ||= File.join(self.root, "public") + @@public_path ||= self.root ? File.join(self.root, "public") : "public" end def public_path=(path) -- cgit v1.2.3 From 926f4648f0628009336c44f4d31019819434e39c Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 1 May 2008 17:26:31 -0500 Subject: Made the location of the routes file configurable with config.routes_configuration_file (Scott Fleckenstein) [#88 state:resolved] --- railties/lib/initializer.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'railties/lib') diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index 09a98d5aa3..5fd7149858 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -386,6 +386,7 @@ module Rails def initialize_routing return unless configuration.frameworks.include?(:action_controller) ActionController::Routing.controller_paths = configuration.controller_paths + ActionController::Routing::Routes.configuration_file = configuration.routes_configuration_file ActionController::Routing::Routes.reload end @@ -503,6 +504,10 @@ module Rails # The path to the database configuration file to use. (Defaults to # config/database.yml.) attr_accessor :database_configuration_file + + # The path to the routes configuration file to use. (Defaults to + # config/routes.rb.) + attr_accessor :routes_configuration_file # The list of rails framework components that should be loaded. (Defaults # to :active_record, :action_controller, @@ -635,6 +640,7 @@ module Rails self.plugin_locators = default_plugin_locators self.plugin_loader = default_plugin_loader self.database_configuration_file = default_database_configuration_file + self.routes_configuration_file = default_routes_configuration_file self.gems = default_gems for framework in default_frameworks @@ -775,6 +781,10 @@ module Rails File.join(root_path, 'config', 'database.yml') end + def default_routes_configuration_file + File.join(root_path, 'config', 'routes.rb') + end + def default_view_path File.join(root_path, 'app', 'views') end -- cgit v1.2.3 From 64092de25727c1943807bf5345107d90428135a0 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Fri, 2 May 2008 14:45:23 +0100 Subject: Improve documentation coverage and markup Signed-off-by: Pratik Naik --- railties/lib/initializer.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index 5fd7149858..6db96f0158 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -572,11 +572,11 @@ module Rails attr_accessor :plugin_loader # Enables or disables plugin reloading. You can get around this setting per plugin. - # If #reload_plugins? == false, add this to your plugin's init.rb to make it reloadable: + # If reload_plugins? is false, add this to your plugin's init.rb to make it reloadable: # # Dependencies.load_once_paths.delete lib_path # - # If #reload_plugins? == true, add this to your plugin's init.rb to only load it once: + # If reload_plugins? is true, add this to your plugin's init.rb to only load it once: # # Dependencies.load_once_paths << lib_path # -- cgit v1.2.3 From 205750c8dead2449a23173fab0720b7701231d2a Mon Sep 17 00:00:00 2001 From: Pete Deffendol Date: Tue, 22 Apr 2008 14:23:17 -0600 Subject: PostgreSQL: Connect to template1 database when creating or dropping db * The template1 database is always available on a PostgreSQL install * The previous behavior expected a database with the same name as the connecting user, which may not be available Signed-off-by: Michael Koziarski [#38 state:resolved] --- railties/lib/tasks/databases.rake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/tasks/databases.rake b/railties/lib/tasks/databases.rake index e39f9ca197..20fdcce205 100644 --- a/railties/lib/tasks/databases.rake +++ b/railties/lib/tasks/databases.rake @@ -45,7 +45,7 @@ namespace :db do when 'postgresql' @encoding = config[:encoding] || ENV['CHARSET'] || 'utf8' begin - ActiveRecord::Base.establish_connection(config.merge('database' => nil)) + ActiveRecord::Base.establish_connection(config.merge('database' => 'template1')) ActiveRecord::Base.connection.create_database(config['database'], :encoding => @encoding) ActiveRecord::Base.establish_connection(config) rescue @@ -373,7 +373,7 @@ def drop_database(config) when /^sqlite/ FileUtils.rm(File.join(RAILS_ROOT, config['database'])) when 'postgresql' - ActiveRecord::Base.establish_connection(config.merge('database' => nil)) + ActiveRecord::Base.establish_connection(config.merge('database' => 'template1')) ActiveRecord::Base.connection.drop_database config['database'] end end -- cgit v1.2.3 From 437f918646fd141fd57350f55a8890b18ebfb148 Mon Sep 17 00:00:00 2001 From: Michael Koziarski Date: Sun, 4 May 2008 12:31:34 +1200 Subject: Allow custom loggers to work with script/server. Instead of requiring the initializer and initializing the logger, create the file manually before tailing it. [atnan] Closes #8665 (trac) --- railties/lib/commands/servers/mongrel.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/commands/servers/mongrel.rb b/railties/lib/commands/servers/mongrel.rb index 5eb14bce1e..f59265e698 100644 --- a/railties/lib/commands/servers/mongrel.rb +++ b/railties/lib/commands/servers/mongrel.rb @@ -34,10 +34,10 @@ end puts "=> Rails application starting on http://#{OPTIONS[:ip]}:#{OPTIONS[:port]}" -parameters = [ - "start", - "-p", OPTIONS[:port].to_s, - "-a", OPTIONS[:ip].to_s, +parameters = [ + "start", + "-p", OPTIONS[:port].to_s, + "-a", OPTIONS[:ip].to_s, "-e", OPTIONS[:environment], "-P", "#{RAILS_ROOT}/tmp/pids/mongrel.pid" ] @@ -50,12 +50,12 @@ else start_debugger if OPTIONS[:debugger] - require 'initializer' - Rails::Initializer.run(:initialize_logger) - puts "=> Call with -d to detach" puts "=> Ctrl-C to shutdown server" - tail_thread = tail(Pathname.new("#{File.expand_path(RAILS_ROOT)}/log/#{RAILS_ENV}.log").cleanpath) + + log = Pathname.new("#{File.expand_path(RAILS_ROOT)}/log/#{RAILS_ENV}.log").cleanpath + open(log, (File::WRONLY | File::APPEND | File::CREAT)) unless File.exist? log + tail_thread = tail(log) trap(:INT) { exit } -- cgit v1.2.3