From 92e2e5990cc2aa4f699c286ac5d1f73e27ede548 Mon Sep 17 00:00:00 2001 From: rick Date: Tue, 6 May 2008 01:20:59 -0700 Subject: include bugfix to [e792d4ab70448f79142fdf492390682ff5ea6398] for rubygems 1.0.1. Gem::DependencyList#dependency_order was bombing with nil specs passed in from a frozen gem. [#122] --- railties/lib/rails/plugin/locator.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'railties') 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 rails/init.rb 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" -- cgit v1.2.3 From 80e18e759e5244bbffd637e306f4f18b92af5caf Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Sun, 11 May 2008 23:51:30 +0100 Subject: Ensure dbconsole respects erb in database.yml. [#157 state:resolved] [Andrew Bennett] Signed-off-by: Pratik Naik --- railties/lib/commands/dbconsole.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'railties') 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 -- cgit v1.2.3 From 5d9c6026984d91e940a28f221ba558124cc027cb Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 11 May 2008 18:21:19 -0500 Subject: Depend on latest Rake --- railties/Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/Rakefile b/railties/Rakefile index 4eaa1bef63..bb3aa4826e 100644 --- a/railties/Rakefile +++ b/railties/Rakefile @@ -303,7 +303,7 @@ spec = Gem::Specification.new do |s| on top of either MySQL, PostgreSQL, SQLite, DB2, SQL Server, or Oracle with eRuby- or Builder-based templates. EOF - s.add_dependency('rake', '>= 0.7.2') + s.add_dependency('rake', '>= 0.8.1') s.add_dependency('activesupport', '= 2.0.2' + PKG_BUILD) s.add_dependency('activerecord', '= 2.0.2' + PKG_BUILD) s.add_dependency('actionpack', '= 2.0.2' + PKG_BUILD) -- cgit v1.2.3 From b60c8a573e63998b4aa3f93a1728bb9b6c6fb8f9 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 11 May 2008 18:29:44 -0500 Subject: Making ready for RC1 release --- railties/CHANGELOG | 2 +- railties/Rakefile | 10 +++++----- railties/lib/rails/version.rb | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'railties') diff --git a/railties/CHANGELOG b/railties/CHANGELOG index 2ca1965d97..11d2926f31 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,4 +1,4 @@ -*SVN* +*2.1.0 RC1 (May 11th, 2008)* * script/dbconsole fires up the command-line database client. #102 [Steve Purcell] diff --git a/railties/Rakefile b/railties/Rakefile index bb3aa4826e..45ba394299 100644 --- a/railties/Rakefile +++ b/railties/Rakefile @@ -304,11 +304,11 @@ spec = Gem::Specification.new do |s| EOF s.add_dependency('rake', '>= 0.8.1') - s.add_dependency('activesupport', '= 2.0.2' + PKG_BUILD) - s.add_dependency('activerecord', '= 2.0.2' + PKG_BUILD) - s.add_dependency('actionpack', '= 2.0.2' + PKG_BUILD) - s.add_dependency('actionmailer', '= 2.0.2' + PKG_BUILD) - s.add_dependency('activeresource', '= 2.0.2' + PKG_BUILD) + s.add_dependency('activesupport', '= 2.0.991' + PKG_BUILD) + s.add_dependency('activerecord', '= 2.0.991' + PKG_BUILD) + s.add_dependency('actionpack', '= 2.0.991' + PKG_BUILD) + s.add_dependency('actionmailer', '= 2.0.991' + PKG_BUILD) + s.add_dependency('activeresource', '= 2.0.991' + PKG_BUILD) s.rdoc_options << '--exclude' << '.' s.has_rdoc = false 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 -- cgit v1.2.3 From 00640de861797b258d2dd955b861bcb021d4a3e1 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 11 May 2008 18:34:05 -0500 Subject: Updated copyright years --- railties/MIT-LICENSE | 2 +- railties/html/javascripts/controls.js | 2 +- railties/html/javascripts/dragdrop.js | 2 +- railties/html/javascripts/effects.js | 2 +- railties/lib/dispatcher.rb | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'railties') diff --git a/railties/MIT-LICENSE b/railties/MIT-LICENSE index 5fee6e106d..93be57f683 100644 --- a/railties/MIT-LICENSE +++ b/railties/MIT-LICENSE @@ -1,4 +1,4 @@ -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/html/javascripts/controls.js b/railties/html/javascripts/controls.js index fbc4418b83..5aaf0bb2b7 100644 --- a/railties/html/javascripts/controls.js +++ b/railties/html/javascripts/controls.js @@ -1,4 +1,4 @@ -// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) +// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // (c) 2005-2007 Ivan Krstic (http://blogs.law.harvard.edu/ivan) // (c) 2005-2007 Jon Tirsen (http://www.tirsen.com) // Contributors: diff --git a/railties/html/javascripts/dragdrop.js b/railties/html/javascripts/dragdrop.js index ccf4a1e45c..bf5cfea66c 100644 --- a/railties/html/javascripts/dragdrop.js +++ b/railties/html/javascripts/dragdrop.js @@ -1,4 +1,4 @@ -// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) +// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // (c) 2005-2007 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz) // // script.aculo.us is freely distributable under the terms of an MIT-style license. diff --git a/railties/html/javascripts/effects.js b/railties/html/javascripts/effects.js index 65aed23957..f030b5dbe9 100644 --- a/railties/html/javascripts/effects.js +++ b/railties/html/javascripts/effects.js @@ -1,4 +1,4 @@ -// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) +// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // Contributors: // Justin Palmer (http://encytemedia.com/) // Mark Pilgrim (http://diveintomark.org/) 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 -- cgit v1.2.3 From cbd5db8f5165f013069b02414f9bf762d88f619f Mon Sep 17 00:00:00 2001 From: Manik Juneja Date: Mon, 12 May 2008 23:43:31 +0530 Subject: minor changes in railties/README. Added dbconsole introduction --- railties/README | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'railties') diff --git a/railties/README b/railties/README index b5f4eee4b7..2af0fb1133 100644 --- a/railties/README +++ b/railties/README @@ -145,7 +145,9 @@ and also on programming in general. Debugger support is available through the debugger command when you start your Mongrel or Webrick server with --debugger. This means that you can break out of execution at any point -in the code, investigate and change the model, AND then resume execution! Example: +in the code, investigate and change the model, AND then resume execution! +You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug' +Example: class WeblogController < ActionController::Base def index @@ -183,6 +185,13 @@ Passing an argument will specify a different environment, like script/consol To reload your controllers and models after launching the console run reload! +== dbconsole + +You can go to the command line of your database directly through script/dbconsole. +You would be connected to the database with the credentials defined in database.yml. +Starting the script without arguments will connect you to the development database. Passing an +argument will connect you to a different database, like script/dbconsole production. +Currently works for mysql, postgresql and sqlite. == Description of Contents @@ -200,13 +209,13 @@ app/models app/views Holds the template files for the view that should be named like - weblogs/index.erb for the WeblogsController#index action. All views use eRuby + weblogs/index.html.erb for the WeblogsController#index action. All views use eRuby syntax. app/views/layouts Holds the template files for layouts to be used with views. This models the common header/footer method of wrapping views. In your views, define a layout using the - layout :default and create a file named default.erb. Inside default.erb, + layout :default and create a file named default.html.erb. Inside default.html.erb, call <% yield %> to render the view using this layout. app/helpers @@ -243,4 +252,5 @@ test vendor External libraries that the application depends on. Also includes the plugins subdirectory. + If the app has frozen rails, those gems also go here, under vendor/rails/. This directory is in the load path. -- cgit v1.2.3 From 9fb01ce4b194567e84fa2f8582410fc76720a31f Mon Sep 17 00:00:00 2001 From: Matthew Brindley Date: Mon, 12 May 2008 13:20:54 +1200 Subject: ScaffoldGenerator to create public/stylesheets if missing. [#165 state:resolved] Signed-off-by: Pratik Naik --- .../generators/components/scaffold/scaffold_generator.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'railties') 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( -- cgit v1.2.3 From 4dedc7ddcaffa8c606af11ae2d32707131b99a2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20T=C3=A4nav?= Date: Tue, 13 May 2008 17:26:05 +0300 Subject: Use 'postgres' database instead of 'template1' The 'postgres' database is meant for use by utilities and third party applications. CONNECT permission to the 'template1' database is usually only available to superusers which is why 'postgres' should be preferred as users whith "CREATE DATABASE" permissions are not neccessarily superusers. --- railties/lib/tasks/databases.rake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties') diff --git a/railties/lib/tasks/databases.rake b/railties/lib/tasks/databases.rake index 63f71448f8..fe099e30b9 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')) 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')) ActiveRecord::Base.connection.drop_database config['database'] end end -- cgit v1.2.3 From 3fee2378edd45188e41a7d14d4ca0a88280b541e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarmo=20T=C3=A4nav?= Date: Tue, 13 May 2008 20:20:52 +0300 Subject: Use 'public' schema path when connecting to 'postgres' database. [#170 state:resolved] Signed-off-by: Pratik Naik --- railties/lib/tasks/databases.rake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties') diff --git a/railties/lib/tasks/databases.rake b/railties/lib/tasks/databases.rake index fe099e30b9..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' => 'postgres')) + 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' => 'postgres')) + ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public')) ActiveRecord::Base.connection.drop_database config['database'] end end -- cgit v1.2.3 From 4562a5b57f5999fadc8b0957ed5777f35be8dea5 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Tue, 13 May 2008 15:49:41 -0500 Subject: Add some test coverage for RailsControllerGenerator. --- railties/test/generators/generator_test_helper.rb | 34 +++++++++++++++------- .../generators/rails_controller_generator_test.rb | 20 +++++++++++++ 2 files changed, 44 insertions(+), 10 deletions(-) create mode 100644 railties/test/generators/rails_controller_generator_test.rb (limited to 'railties') diff --git a/railties/test/generators/generator_test_helper.rb b/railties/test/generators/generator_test_helper.rb index 190bc91d52..c99df6e2d3 100644 --- a/railties/test/generators/generator_test_helper.rb +++ b/railties/test/generators/generator_test_helper.rb @@ -13,7 +13,7 @@ module ActiveRecord module ConnectionAdapters class Column attr_reader :name, :default, :type, :limit, :null, :sql_type, :precision, :scale - + def initialize(name, default, sql_type = nil) @name = name @default = default @@ -59,16 +59,16 @@ require 'rails_generator' class GeneratorTestCase < Test::Unit::TestCase include FileUtils - + def setup ActiveRecord::Base.pluralize_table_names = true - + mkdir_p "#{RAILS_ROOT}/app/views/layouts" mkdir_p "#{RAILS_ROOT}/config" mkdir_p "#{RAILS_ROOT}/db" mkdir_p "#{RAILS_ROOT}/test/fixtures" mkdir_p "#{RAILS_ROOT}/public/stylesheets" - + File.open("#{RAILS_ROOT}/config/routes.rb", 'w') do |f| f << "ActionController::Routing::Routes.draw do |map|\n\nend" end @@ -85,7 +85,7 @@ class GeneratorTestCase < Test::Unit::TestCase def test_truth # don't complain, test/unit end - + # Instantiates the Generator def build_generator(name, params) Rails::Generator::Base.instance(name, params) @@ -171,9 +171,16 @@ class GeneratorTestCase < Test::Unit::TestCase # asserts that the given class source file was generated. # It takes a path without the .rb part and an optional super class. # the contents of the class source file is passed to a block. - def assert_generated_class(path, parent=nil) - path =~ /\/?(\d+_)?(\w+)$/ - class_name = $2.camelize + def assert_generated_class(path, parent = nil) + # FIXME: Sucky way to detect namespaced classes + if path.split('/').size > 3 + path =~ /\/?(\d+_)?(\w+)\/(\w+)$/ + class_name = "#{$2.camelize}::#{$3.camelize}" + else + path =~ /\/?(\d+_)?(\w+)$/ + class_name = $2.camelize + end + assert_generated_file("#{path}.rb") do |body| assert_match /class #{class_name}#{parent.nil? ? '':" < #{parent}"}/, body, "the file '#{path}.rb' should be a class" yield body if block_given? @@ -184,8 +191,15 @@ class GeneratorTestCase < Test::Unit::TestCase # It takes a path without the .rb part. # the contents of the class source file is passed to a block. def assert_generated_module(path) - path =~ /\/?(\w+)$/ - module_name = $1.camelize + # FIXME: Sucky way to detect namespaced modules + if path.split('/').size > 3 + path =~ /\/?(\w+)\/(\w+)$/ + module_name = "#{$1.camelize}::#{$2.camelize}" + else + path =~ /\/?(\w+)$/ + module_name = $1.camelize + end + assert_generated_file("#{path}.rb") do |body| assert_match /module #{module_name}/, body, "the file '#{path}.rb' should be a module" yield body if block_given? diff --git a/railties/test/generators/rails_controller_generator_test.rb b/railties/test/generators/rails_controller_generator_test.rb new file mode 100644 index 0000000000..0090d21b85 --- /dev/null +++ b/railties/test/generators/rails_controller_generator_test.rb @@ -0,0 +1,20 @@ +require 'generators/generator_test_helper' + +class RailsControllerGeneratorTest < GeneratorTestCase + + def test_controller_generates_controller + run_generator('controller', %w(products)) + + assert_generated_controller_for :products + assert_generated_functional_test_for :products + assert_generated_helper_for :products + end + + def test_controller_generates_namespaced_controller + run_generator('controller', %w(admin::products)) + + assert_generated_controller_for "admin::products" + assert_generated_functional_test_for "admin::products" + assert_generated_helper_for "admin::products" + end +end -- cgit v1.2.3 From 2d372d704987e05712ccd937e78d8dbd41242efe Mon Sep 17 00:00:00 2001 From: Amol Hatwar Date: Tue, 13 May 2008 16:02:56 -0500 Subject: Fixed generator collisions for nested controller modules. Signed-off-by: Joshua Peek --- railties/lib/rails_generator/commands.rb | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'railties') 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 -- cgit v1.2.3 From bca8751e40a5594c4de2ca58e089b8d98e44632b Mon Sep 17 00:00:00 2001 From: Rodrigo Kochenburger Date: Fri, 11 Apr 2008 12:35:09 -0300 Subject: Add ActiveRecord option to store the full class name on STI's type column, allowing one to have STI subclasses in different namespaces [#114] Signed-off-by: rick --- railties/configs/initializers/new_rails_defaults.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'railties') diff --git a/railties/configs/initializers/new_rails_defaults.rb b/railties/configs/initializers/new_rails_defaults.rb index 3a617e3ae3..b8f0e2cac2 100644 --- a/railties/configs/initializers/new_rails_defaults.rb +++ b/railties/configs/initializers/new_rails_defaults.rb @@ -7,6 +7,9 @@ ActiveRecord::Base.partial_updates = true # Include ActiveRecord class name as root for JSON serialized output. ActiveRecord::Base.include_root_in_json = true +# Store the full class name (including module namespace) in STI type column +ActiveRecord::Base.store_full_sti_class = true + # Use ISO 8601 format for JSON serialized times and dates ActiveSupport.use_standard_json_time_format = true -- cgit v1.2.3