diff options
Diffstat (limited to 'railties')
-rw-r--r-- | railties/CHANGELOG | 5 | ||||
-rw-r--r-- | railties/Rakefile | 8 | ||||
-rw-r--r-- | railties/configs/seeds.rb | 7 | ||||
-rw-r--r-- | railties/lib/console_app.rb | 5 | ||||
-rw-r--r-- | railties/lib/initializer.rb | 4 | ||||
-rw-r--r-- | railties/lib/rails/plugin.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/rack/metal.rb | 3 | ||||
-rw-r--r-- | railties/lib/rails_generator/generators/applications/app/app_generator.rb | 5 | ||||
-rw-r--r-- | railties/lib/tasks/databases.rake | 13 | ||||
-rw-r--r-- | railties/lib/tasks/gems.rake | 3 | ||||
-rw-r--r-- | railties/test/abstract_unit.rb | 1 | ||||
-rw-r--r-- | railties/test/plugin_test_helper.rb | 1 |
12 files changed, 45 insertions, 12 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG index 98e3a861e8..8e7dfb38cc 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,3 +1,8 @@ +*Edge* + +* Added db/seeds.rb as a default file for storing seed data for the database. Can be loaded with rake db:seed (or created alongside the db with db:setup). (This is also known as the "Stop Putting Gawd Damn Seed Data In Your Migrations" feature) [DHH] + + *2.3.2 [Final] (March 15, 2009)* * Remove outdated script/plugin options [Pratik Naik] diff --git a/railties/Rakefile b/railties/Rakefile index 9cd102df0f..133a603ed6 100644 --- a/railties/Rakefile +++ b/railties/Rakefile @@ -2,7 +2,6 @@ require 'rake' require 'rake/testtask' require 'rake/rdoctask' require 'rake/gempackagetask' -require 'rake/contrib/rubyforgepublisher' require 'date' require 'rbconfig' @@ -32,6 +31,7 @@ task :test do system(ruby, '-Itest', "-I#{File.dirname(__FILE__)}/../activesupport/lib", file) end or raise "Failures" end +task :isolated_test => :test Rake::TestTask.new("regular_test") do |t| t.libs << 'test' << "#{File.dirname(__FILE__)}/../activesupport/lib" @@ -200,11 +200,14 @@ task :copy_configs do cp "configs/locales/en.yml", "#{PKG_DESTINATION}/config/locales/en.yml" + cp "configs/seeds.rb", "#{PKG_DESTINATION}/db/seeds.rb" + cp "environments/boot.rb", "#{PKG_DESTINATION}/config/boot.rb" cp "environments/environment.rb", "#{PKG_DESTINATION}/config/environment.rb" cp "environments/production.rb", "#{PKG_DESTINATION}/config/environments/production.rb" cp "environments/development.rb", "#{PKG_DESTINATION}/config/environments/development.rb" cp "environments/test.rb", "#{PKG_DESTINATION}/config/environments/test.rb" + end task :copy_binfiles do @@ -341,12 +344,14 @@ end # Publishing ------------------------------------------------------- desc "Publish the rails gem" task :pgem => [:gem] do + require 'rake/contrib/sshpublisher' Rake::SshFilePublisher.new("gems.rubyonrails.org", "/u/sites/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload `ssh gems.rubyonrails.org '/u/sites/gems/gemupdate.sh'` end desc "Publish the guides" task :pguides => :guides do + require 'rake/contrib/sshpublisher' mkdir_p 'pkg' `tar -czf pkg/guides.gz guides/output` Rake::SshFilePublisher.new("web.rubyonrails.org", "/u/sites/guides.rubyonrails.org/public", "pkg", "guides.gz").upload @@ -355,6 +360,7 @@ end desc "Publish the release files to RubyForge." task :release => [ :package ] do + require 'rake/contrib/rubyforgepublisher' require 'rubyforge' packages = %w( gem ).collect{ |ext| "pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}" } diff --git a/railties/configs/seeds.rb b/railties/configs/seeds.rb new file mode 100644 index 0000000000..3174d0cb8a --- /dev/null +++ b/railties/configs/seeds.rb @@ -0,0 +1,7 @@ +# This file should contain all the record creation needed to seed the database with its default values. +# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). +# +# Examples: +# +# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) +# Major.create(:name => 'Daley', :city => cities.first) diff --git a/railties/lib/console_app.rb b/railties/lib/console_app.rb index 5c8302634a..c944d49205 100644 --- a/railties/lib/console_app.rb +++ b/railties/lib/console_app.rb @@ -26,7 +26,8 @@ end #reloads the environment def reload! puts "Reloading..." - Dispatcher.cleanup_application - Dispatcher.reload_application + dispatcher = ActionController::Dispatcher.new + dispatcher.cleanup_application + dispatcher.reload_application true end diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index 71366a4480..40000f0dfd 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -264,8 +264,8 @@ module Rails # Action Pack, Action Mailer, and Active Resource) are loaded. def require_frameworks require 'active_support' - require 'active_support/core/all' configuration.frameworks.each { |framework| require(framework.to_s) } + require 'active_support/core/all' rescue LoadError => e # Re-raise as RuntimeError because Mongrel would swallow LoadError. raise e.to_s @@ -462,7 +462,7 @@ Run `rake gems:install` to install the missing gems. if RAILS_CACHE.respond_to?(:middleware) # Insert middleware to setup and teardown local cache for each request - configuration.middleware.insert_after(:"ActionController::Failsafe", RAILS_CACHE.middleware) + configuration.middleware.insert_after(:"ActionDispatch::Failsafe", RAILS_CACHE.middleware) end end end diff --git a/railties/lib/rails/plugin.rb b/railties/lib/rails/plugin.rb index 0f924724cd..e66166306a 100644 --- a/railties/lib/rails/plugin.rb +++ b/railties/lib/rails/plugin.rb @@ -1,3 +1,5 @@ +require 'active_support/core_ext/kernel/reporting' + module Rails # The Plugin class should be an object which provides the following methods: # diff --git a/railties/lib/rails/rack/metal.rb b/railties/lib/rails/rack/metal.rb index 7a616c7911..b031be29af 100644 --- a/railties/lib/rails/rack/metal.rb +++ b/railties/lib/rails/rack/metal.rb @@ -1,5 +1,6 @@ require 'active_support/ordered_hash' require 'active_support/core_ext/class/attribute_accessors' +require 'active_support/dependencies' module Rails module Rack @@ -27,7 +28,7 @@ module Rails load_list.map do |requested_metal| if metal = all_metals[requested_metal] - require metal + require_dependency metal requested_metal.constantize end end.compact diff --git a/railties/lib/rails_generator/generators/applications/app/app_generator.rb b/railties/lib/rails_generator/generators/applications/app/app_generator.rb index 2c31d89538..c8c2239f34 100644 --- a/railties/lib/rails_generator/generators/applications/app/app_generator.rb +++ b/railties/lib/rails_generator/generators/applications/app/app_generator.rb @@ -125,6 +125,7 @@ class AppGenerator < Rails::Generator::Base create_database_configuration_file(m) create_routes_file(m) create_locale_file(m) + create_seeds_file(m) create_initializer_files(m) create_environment_files(m) end @@ -176,6 +177,10 @@ class AppGenerator < Rails::Generator::Base m.file "configs/routes.rb", "config/routes.rb" end + def create_seeds_file(m) + m.file "configs/seeds.rb", "db/seeds.rb" + end + def create_initializer_files(m) %w( backtrace_silencers diff --git a/railties/lib/tasks/databases.rake b/railties/lib/tasks/databases.rake index 9588fabb2d..cdab5d8bb0 100644 --- a/railties/lib/tasks/databases.rake +++ b/railties/lib/tasks/databases.rake @@ -156,8 +156,8 @@ namespace :db do Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby end - desc 'Drops and recreates the database from db/schema.rb for the current environment.' - task :reset => ['db:drop', 'db:create', 'db:schema:load'] + desc 'Drops and recreates the database from db/schema.rb for the current environment and loads the seeds.' + task :reset => [ 'db:drop', 'db:setup' ] desc "Retrieves the charset for the current environment's database" task :charset => :environment do @@ -206,6 +206,15 @@ namespace :db do end end + desc 'Create the database, load the schema, and initialize with the seed data' + task :setup => [ 'db:create', 'db:schema:load', 'db:seed' ] + + desc 'Load the seed data from db/seeds.rb' + task :seed => :environment do + seed_file = File.join(Rails.root, 'db', 'seeds.rb') + load(seed_file) if File.exist?(seed_file) + end + namespace :fixtures do desc "Load fixtures into the current environment's database. Load specific fixtures using FIXTURES=x,y. Load from subdirectory in test/fixtures using FIXTURES_DIR=z. Specify an alternative path (eg. spec/fixtures) using FIXTURES_PATH=spec/fixtures." task :load => :environment do diff --git a/railties/lib/tasks/gems.rake b/railties/lib/tasks/gems.rake index efadb1da3b..7cf7061f38 100644 --- a/railties/lib/tasks/gems.rake +++ b/railties/lib/tasks/gems.rake @@ -27,8 +27,7 @@ namespace :gems do desc "Force the build of all gems" task :force do $gems_build_rake_task = true - Rake::Task['gems:unpack'].invoke - current_gems.each { |gem| gem.build(:force => true) } + frozen_gems.each { |gem| gem.build(:force => true) } end end diff --git a/railties/test/abstract_unit.rb b/railties/test/abstract_unit.rb index ffd60ee662..0addcb8bf3 100644 --- a/railties/test/abstract_unit.rb +++ b/railties/test/abstract_unit.rb @@ -13,7 +13,6 @@ gem 'mocha', '>= 0.9.5' require 'mocha' require 'active_support' -require 'active_support/core/all' require 'active_support/test_case' if defined?(RAILS_ROOT) diff --git a/railties/test/plugin_test_helper.rb b/railties/test/plugin_test_helper.rb index adb62de665..55d1a1fa96 100644 --- a/railties/test/plugin_test_helper.rb +++ b/railties/test/plugin_test_helper.rb @@ -3,7 +3,6 @@ $:.unshift File.dirname(__FILE__) + "/../../activesupport/lib" require 'test/unit' require 'active_support' -require 'active_support/core/all' require 'initializer' require File.join(File.dirname(__FILE__), 'abstract_unit') |