aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib')
-rw-r--r--railties/lib/commands/dbconsole.rb3
-rw-r--r--railties/lib/dispatcher.rb2
-rw-r--r--railties/lib/rails/plugin/locator.rb5
-rw-r--r--railties/lib/rails/version.rb2
-rw-r--r--railties/lib/rails_generator/commands.rb25
-rw-r--r--railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb3
-rw-r--r--railties/lib/tasks/databases.rake4
7 files changed, 27 insertions, 17 deletions
diff --git a/railties/lib/commands/dbconsole.rb b/railties/lib/commands/dbconsole.rb
index 28c3a3e41f..3e5010c688 100644
--- a/railties/lib/commands/dbconsole.rb
+++ b/railties/lib/commands/dbconsole.rb
@@ -1,3 +1,4 @@
+require 'erb'
require 'yaml'
require 'optparse'
@@ -8,7 +9,7 @@ OptionParser.new do |opt|
end
env = ARGV.first || ENV['RAILS_ENV'] || 'development'
-unless config = YAML.load_file(RAILS_ROOT + "/config/database.yml")[env]
+unless config = YAML::load(ERB.new(IO.read(RAILS_ROOT + "/config/database.yml")).result)[env]
abort "No database is configured for the environment '#{env}'"
end
diff --git a/railties/lib/dispatcher.rb b/railties/lib/dispatcher.rb
index 9db424f14b..0bad45d9d8 100644
--- a/railties/lib/dispatcher.rb
+++ b/railties/lib/dispatcher.rb
@@ -1,5 +1,5 @@
#--
-# Copyright (c) 2004-2007 David Heinemeier Hansson
+# Copyright (c) 2004-2008 David Heinemeier Hansson
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
diff --git a/railties/lib/rails/plugin/locator.rb b/railties/lib/rails/plugin/locator.rb
index fd7de4ee28..f06a51a572 100644
--- a/railties/lib/rails/plugin/locator.rb
+++ b/railties/lib/rails/plugin/locator.rb
@@ -78,11 +78,12 @@ module Rails
# a <tt>rails/init.rb</tt> file.
class GemLocator < Locator
def plugins
- specs = initializer.configuration.gems.map(&:specification)
- specs + Gem.loaded_specs.values.select do |spec|
+ specs = initializer.configuration.gems.map(&:specification)
+ specs += Gem.loaded_specs.values.select do |spec|
spec.loaded_from && # prune stubs
File.exist?(File.join(spec.full_gem_path, "rails", "init.rb"))
end
+ specs.compact!
require "rubygems/dependency_list"
diff --git a/railties/lib/rails/version.rb b/railties/lib/rails/version.rb
index da90645738..fea63beea9 100644
--- a/railties/lib/rails/version.rb
+++ b/railties/lib/rails/version.rb
@@ -2,7 +2,7 @@ module Rails
module VERSION #:nodoc:
MAJOR = 2
MINOR = 0
- TINY = 2
+ TINY = 991
STRING = [MAJOR, MINOR, TINY].join('.')
end
diff --git a/railties/lib/rails_generator/commands.rb b/railties/lib/rails_generator/commands.rb
index 440bab276c..03b7d354a6 100644
--- a/railties/lib/rails_generator/commands.rb
+++ b/railties/lib/rails_generator/commands.rb
@@ -154,28 +154,35 @@ HELP
# Ruby or Rails. In the future, expand to check other namespaces
# such as the rest of the user's app.
def class_collisions(*class_names)
+
+ # Initialize some check varibles
+ last_class = Object
+ current_class = nil
+ name = nil
+
class_names.flatten.each do |class_name|
# Convert to string to allow symbol arguments.
class_name = class_name.to_s
# Skip empty strings.
- next if class_name.strip.empty?
+ class_name.strip.empty? ? next : current_class = class_name
# Split the class from its module nesting.
nesting = class_name.split('::')
name = nesting.pop
# Extract the last Module in the nesting.
- last = nesting.inject(Object) { |last, nest|
- break unless last.const_defined?(nest)
- last.const_get(nest)
+ last = nesting.inject(last_class) { |last, nest|
+ break unless last_class.const_defined?(nest)
+ last_class = last_class.const_get(nest)
}
- # If the last Module exists, check whether the given
- # class exists and raise a collision if so.
- if last and last.const_defined?(name.camelize)
- raise_class_collision(class_name)
- end
+ end
+ # If the last Module exists, check whether the given
+ # class exists and raise a collision if so.
+
+ if last_class and last_class.const_defined?(name.camelize)
+ raise_class_collision(current_class)
end
end
diff --git a/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb b/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb
index 864a0bc528..e2902bf4b9 100644
--- a/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb
+++ b/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb
@@ -34,7 +34,7 @@ class ScaffoldGenerator < Rails::Generator::NamedBase
m.class_collisions(controller_class_path, "#{controller_class_name}Controller", "#{controller_class_name}Helper")
m.class_collisions(class_path, "#{class_name}")
- # Controller, helper, views, and test directories.
+ # Controller, helper, views, test and stylesheets directories.
m.directory(File.join('app/models', class_path))
m.directory(File.join('app/controllers', controller_class_path))
m.directory(File.join('app/helpers', controller_class_path))
@@ -42,6 +42,7 @@ class ScaffoldGenerator < Rails::Generator::NamedBase
m.directory(File.join('app/views/layouts', controller_class_path))
m.directory(File.join('test/functional', controller_class_path))
m.directory(File.join('test/unit', class_path))
+ m.directory(File.join('public/stylesheets', class_path))
for action in scaffold_views
m.template(
diff --git a/railties/lib/tasks/databases.rake b/railties/lib/tasks/databases.rake
index 63f71448f8..f40f8463f7 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' => 'template1'))
+ ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public'))
ActiveRecord::Base.connection.create_database(config['database'], config.merge('encoding' => @encoding))
ActiveRecord::Base.establish_connection(config)
rescue
@@ -368,7 +368,7 @@ def drop_database(config)
when /^sqlite/
FileUtils.rm(File.join(RAILS_ROOT, config['database']))
when 'postgresql'
- ActiveRecord::Base.establish_connection(config.merge('database' => 'template1'))
+ ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public'))
ActiveRecord::Base.connection.drop_database config['database']
end
end