diff options
author | rick <rick@spacemonkey.local> | 2008-05-05 23:19:21 -0700 |
---|---|---|
committer | rick <rick@spacemonkey.local> | 2008-05-05 23:19:21 -0700 |
commit | 0052938ac5b8894b27fdb9f27b1ed39f0a9ea176 (patch) | |
tree | f714643a4043d9fb73b39ec2a114d18f5deeffdd /railties/lib | |
parent | eacb5cf0cab6447db78085c8bda6c94dd329ce6b (diff) | |
parent | 3cffe92ff066c2b35eef409547db93652c5cccfc (diff) | |
download | rails-0052938ac5b8894b27fdb9f27b1ed39f0a9ea176.tar.gz rails-0052938ac5b8894b27fdb9f27b1ed39f0a9ea176.tar.bz2 rails-0052938ac5b8894b27fdb9f27b1ed39f0a9ea176.zip |
Merge commit 'core/master'
Diffstat (limited to 'railties/lib')
5 files changed, 39 insertions, 21 deletions
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 } diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index b5bf9266f5..6db96f0158 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) @@ -135,12 +139,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 @@ -160,6 +164,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 @@ -378,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 @@ -495,6 +504,10 @@ module Rails # The path to the database configuration file to use. (Defaults to # <tt>config/database.yml</tt>.) attr_accessor :database_configuration_file + + # The path to the routes configuration file to use. (Defaults to + # <tt>config/routes.rb</tt>.) + attr_accessor :routes_configuration_file # The list of rails framework components that should be loaded. (Defaults # to <tt>:active_record</tt>, <tt>:action_controller</tt>, @@ -559,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 <tt>reload_plugins?</tt> 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 <tt>reload_plugins?</tt> is true, add this to your plugin's init.rb to only load it once: # # Dependencies.load_once_paths << lib_path # @@ -627,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 @@ -767,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 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 -%> <p> - <%%= f.label :<%= attribute.name %> %><br /> + <%%= f.label :<%= attribute.name %> %><br /> <%%= f.<%= attribute.field_type %> :<%= attribute.name %> %> </p> <% 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 -%> <p> - <%%= f.label :<%= attribute.name %> %><br /> + <%%= f.label :<%= attribute.name %> %><br /> <%%= f.<%= attribute.field_type %> :<%= attribute.name %> %> </p> <% end -%> @@ -14,4 +14,4 @@ </p> <%% end %> -<%%= link_to 'Back', <%= plural_name %>_path %>
\ No newline at end of file +<%%= link_to 'Back', <%= plural_name %>_path %> 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 |