rails 0.8.5 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rails might be problematic. Click here for more details.

Files changed (66) hide show
  1. data/CHANGELOG +86 -0
  2. data/README +48 -8
  3. data/Rakefile +87 -108
  4. data/bin/breakpointer +3 -0
  5. data/bin/breakpointer_for_gem +4 -0
  6. data/bin/console +30 -0
  7. data/bin/generate +41 -0
  8. data/bin/rails +1 -1
  9. data/{dispatches/dispatch.servlet → bin/server} +15 -11
  10. data/configs/apache.conf +12 -27
  11. data/configs/database.yml +9 -2
  12. data/dispatches/dispatch.fcgi +2 -2
  13. data/dispatches/dispatch.rb +2 -2
  14. data/doc/index.html +12 -36
  15. data/environments/development.rb +5 -0
  16. data/environments/production.rb +3 -6
  17. data/environments/shared.rb +46 -20
  18. data/environments/shared_for_gem.rb +41 -8
  19. data/environments/test.rb +3 -6
  20. data/fresh_rakefile +25 -21
  21. data/generators/controller/USAGE +28 -0
  22. data/generators/controller/controller_generator.rb +22 -0
  23. data/generators/controller/templates/controller.rb +10 -0
  24. data/generators/{templates/controller_test.erb → controller/templates/functional_test.rb} +1 -1
  25. data/generators/{templates/helper.erb → controller/templates/helper.rb} +0 -0
  26. data/generators/controller/templates/view.rhtml +2 -0
  27. data/generators/mailer/USAGE +27 -0
  28. data/generators/mailer/mailer_generator.rb +22 -0
  29. data/generators/{templates/mailer_action.rhtml → mailer/templates/fixture.rhtml} +0 -0
  30. data/generators/{templates/mailer.erb → mailer/templates/mailer.rb} +4 -4
  31. data/generators/{templates/mailer_test.erb → mailer/templates/unit_test.rb} +2 -10
  32. data/generators/mailer/templates/view.rhtml +3 -0
  33. data/generators/model/USAGE +17 -0
  34. data/generators/model/model_generator.rb +10 -0
  35. data/generators/model/templates/fixtures.yml +1 -0
  36. data/generators/{templates/model.erb → model/templates/model.rb} +0 -2
  37. data/generators/{templates/model_test.erb → model/templates/unit_test.rb} +2 -3
  38. data/generators/scaffold/USAGE +25 -0
  39. data/generators/scaffold/scaffold_generator.rb +53 -0
  40. data/generators/scaffold/templates/controller.rb +57 -0
  41. data/generators/scaffold/templates/fixtures.yml +7 -0
  42. data/generators/scaffold/templates/functional_test.rb +79 -0
  43. data/generators/scaffold/templates/layout.rhtml +11 -0
  44. data/generators/scaffold/templates/style.css +53 -0
  45. data/generators/scaffold/templates/view_edit.rhtml +7 -0
  46. data/generators/scaffold/templates/view_list.rhtml +24 -0
  47. data/generators/scaffold/templates/view_new.rhtml +6 -0
  48. data/generators/scaffold/templates/view_show.rhtml +8 -0
  49. data/helpers/{abstract_application.rb → application.rb} +1 -4
  50. data/helpers/test_helper.rb +4 -5
  51. data/lib/binding_of_caller.rb +81 -0
  52. data/lib/breakpoint.rb +526 -0
  53. data/lib/breakpoint_client.rb +167 -0
  54. data/lib/dispatcher.rb +43 -12
  55. data/lib/rails_generator.rb +175 -0
  56. data/lib/webrick_server.rb +48 -52
  57. metadata +49 -21
  58. data/gem_snapshot +0 -14
  59. data/generators/new_controller.rb +0 -43
  60. data/generators/new_crud.rb +0 -34
  61. data/generators/new_mailer.rb +0 -43
  62. data/generators/new_model.rb +0 -31
  63. data/generators/templates/controller.erb +0 -24
  64. data/generators/templates/controller_view.rhtml +0 -10
  65. data/generators/templates/mailer_fixture.rhtml +0 -4
  66. data/lib/generator.rb +0 -112
@@ -0,0 +1,3 @@
1
+ #!/usr/local/bin/ruby
2
+ $LOAD_PATH << File.dirname(__FILE__) + '/../vendor/railties/lib'
3
+ require 'breakpoint_client'
@@ -0,0 +1,4 @@
1
+ #!/usr/local/bin/ruby
2
+ require 'rubygems'
3
+ require_gem 'rails'
4
+ require 'breakpoint_client'
@@ -0,0 +1,30 @@
1
+ #!/usr/local/bin/ruby
2
+
3
+ if ARGV[0]
4
+ ENV['RAILS_ENV'] = ARGV[0]
5
+ puts "Loading environment..."
6
+ exec "irb -r config/environment.rb -r irb/completion --noinspect"
7
+ else
8
+ puts <<-HELP
9
+
10
+ NAME
11
+ console - interact with the domain model through a environment console (on IRB)
12
+
13
+ SYNOPSIS
14
+ console [environment]
15
+
16
+ DESCRIPTION
17
+ Starts an environment console using IRB that lets you manipulate and interrogate
18
+ the domain model or even trigger controller actions. The database connection and
19
+ configuration available to the web application is already setup.
20
+
21
+ Tab completion is available to see classes and methods on individual objects.
22
+
23
+ EXAMPLE
24
+ console production
25
+
26
+ This will initialize the production environment (as setup in config/database.yml
27
+ and config/environments/production.rb). You would now be ready to start requiring
28
+ models using require_dependency.
29
+ HELP
30
+ end
@@ -0,0 +1,41 @@
1
+ #!/usr/local/bin/ruby
2
+ require File.dirname(__FILE__) + '/../config/environment'
3
+ require 'rails_generator'
4
+
5
+ unless ARGV.empty?
6
+ begin
7
+ name = ARGV.shift
8
+ Rails::Generator.instance(name, ARGV).generate
9
+ rescue Rails::Generator::UsageError => e
10
+ puts e.message
11
+ end
12
+ else
13
+ builtin_generators = Rails::Generator.builtin_generators.join(', ')
14
+ contrib_generators = Rails::Generator.contrib_generators.join(', ')
15
+
16
+ $stderr.puts <<end_usage
17
+ #{$0} generator [args]
18
+
19
+ Rails comes with #{builtin_generators} generators.
20
+ #{$0} controller Login login logout
21
+ #{$0} model Account
22
+ #{$0} mailer AccountMailer
23
+ #{$0} scaffold Account action another_action
24
+
25
+ end_usage
26
+
27
+ unless contrib_generators.empty?
28
+ $stderr.puts " Installed generators (in #{RAILS_ROOT}/generators):"
29
+ $stderr.puts " #{contrib_generators}"
30
+ $stderr.puts
31
+ end
32
+
33
+ $stderr.puts <<end_usage
34
+ More generators are available at http://rubyonrails.org
35
+ 1. Download, for example, auth_controller.zip
36
+ 2. Unzip to directory #{RAILS_ROOT}/generators/auth_controller
37
+ 3. Generate without args for usage information
38
+ #{$0} auth_controller
39
+ end_usage
40
+ exit 0
41
+ end
data/bin/rails CHANGED
@@ -18,7 +18,7 @@ SYNOPSIS
18
18
  DESCRIPTION
19
19
  This generator will create a suggested directory structure, lots of minor helper
20
20
  files, and a default configuration for creating a new Rails application. Once the
21
- generator is done, you're adviced to look at the README in the root of the folder.
21
+ generator is done, you're advised to look at the README in the root of the folder.
22
22
 
23
23
  EXAMPLE
24
24
  rails ~/Code/Ruby/weblog
@@ -1,15 +1,14 @@
1
1
  #!/usr/local/bin/ruby
2
2
 
3
- require File.dirname(__FILE__) + "/../config/environments/production"
4
- require 'webrick_server'
3
+ require 'webrick'
5
4
  require 'optparse'
6
5
 
7
6
  OPTIONS = {
8
- :port => 3000,
9
- :ip => "127.0.0.1",
10
- :cache_classes => false,
11
- :server_root => File.expand_path(File.dirname(__FILE__)),
12
- :server_type => SimpleServer
7
+ :port => 3000,
8
+ :ip => "127.0.0.1",
9
+ :environment => "development",
10
+ :server_root => File.expand_path(File.dirname(__FILE__) + "/../public/"),
11
+ :server_type => WEBrick::SimpleServer
13
12
  }
14
13
 
15
14
  ARGV.options do |opts|
@@ -27,12 +26,12 @@ ARGV.options do |opts|
27
26
  opts.on("-i", "--index=controller", String,
28
27
  "Specifies an index controller that requests for root will go to (instead of congratulations screen)."
29
28
  ) { |OPTIONS[:index_controller]| }
29
+ opts.on("-e", "--environment=name", String,
30
+ "Specifies the environment to run this server under (test/development/production).",
31
+ "Default: development") { |OPTIONS[:environment]| }
30
32
  opts.on("-d", "--daemon",
31
33
  "Make Rails run as a Daemon (only works if fork is available -- meaning on *nix)."
32
- ) { OPTIONS[:server_type] = Daemon }
33
- opts.on("-c", "--cache-classes",
34
- "Caches class compilation which will speed up the serving of requests, but require a server restart on source changes."
35
- ) { |OPTIONS[:cache_classes]| }
34
+ ) { OPTIONS[:server_type] = WEBrick::Daemon }
36
35
 
37
36
  opts.separator ""
38
37
 
@@ -42,4 +41,9 @@ ARGV.options do |opts|
42
41
  opts.parse!
43
42
  end
44
43
 
44
+ ENV["RAILS_ENV"] = OPTIONS[:environment]
45
+ require File.dirname(__FILE__) + "/../config/environment"
46
+ require 'webrick_server'
47
+
48
+ puts "=> Rails application started on http://#{OPTIONS[:ip]}:#{OPTIONS[:port]}"
45
49
  DispatchServlet.dispatch(OPTIONS)
@@ -3,41 +3,26 @@ AddHandler fastcgi-script .fcgi
3
3
  AddHandler cgi-script .cgi
4
4
  Options +FollowSymLinks +ExecCGI
5
5
 
6
-
7
- # Remember to set RubySafeLevel 0 in httpd.conf
8
- <IfModule mod_ruby.c>
9
- RubyRequire apache/ruby-run
10
- <Files dispatch.rb>
11
- SetHandler ruby-object
12
- RubyHandler Apache::RubyRun.instance
13
- </Files>
14
- </IfModule>
15
-
16
-
17
6
  # Make sure that mod_ruby.c has been added and loaded as a module with Apache
18
7
  RewriteEngine On
19
8
 
20
- RewriteRule ^dispatch.servlet$ / [R]
9
+ # Change extension from .cgi to .fcgi to switch to FCGI and to .rb to switch to mod_ruby
10
+ RewriteBase /dispatch.cgi
21
11
 
22
12
  # Enable this rewrite rule to point to the controller/action that should serve root.
23
- # RewriteRule ^$ /controller/action [R]
24
-
25
- # Force fcgi
26
- RewriteRule ^fcgi/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)$ /dispatch.fcgi?controller=$1&action=$2&id=$3 [QSA] [L]
27
- RewriteRule ^fcgi/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)$ /dispatch.fcgi?controller=$1&action=$2 [QSA] [L]
28
- RewriteRule ^fcgi/([-_a-zA-Z0-9]+)/?$ /dispatch.fcgi?controller=$1&action=index [QSA] [L]
13
+ # RewriteRule ^$ /controller/action
29
14
 
30
- # Force mod_ruby
31
- RewriteRule ^mruby/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)$ /dispatch.rb?controller=$1&action=$2&id=$3 [QSA] [L]
32
- RewriteRule ^mruby/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)$ /dispatch.rb?controller=$1&action=$2 [QSA] [L]
33
- RewriteRule ^mruby/([-_a-zA-Z0-9]+)/?$ /dispatch.rb?controller=$1&action=index [QSA] [L]
15
+ # Add missing slash
16
+ RewriteRule ^([-_a-zA-Z0-9]+)$ /$1/ [R]
34
17
 
35
- # Default rewriting rules. Change extension from .cgi to .fcgi to switch to FCGI and to .rb to switch to mod_ruby
36
- RewriteRule ^([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)$ /dispatch.cgi?controller=$1&action=$2&id=$3 [QSA] [L]
37
- RewriteRule ^([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)$ /dispatch.cgi?controller=$1&action=$2 [QSA] [L]
38
- RewriteRule ^([-_a-zA-Z0-9]+)/$ /dispatch.cgi?controller=$1&action=index [QSA] [L]
39
- RewriteRule ^([-_a-zA-Z0-9]+)$ /$1/ [R]
18
+ # Default rewriting rules.
19
+ RewriteRule ^([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/([0-9]+)$ ?controller=$1&action=$2&id=$3 [QSA,L]
20
+ RewriteRule ^([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)$ ?controller=$1&action=$2 [QSA,L]
21
+ RewriteRule ^([-_a-zA-Z0-9]+)/$ ?controller=$1&action=index [QSA,L]
40
22
 
23
+ RewriteRule ^([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/([0-9]+)$ ?module=$1&controller=$2&action=$3&id=$4 [QSA,L]
24
+ RewriteRule ^([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)$ ?module=$1&controller=$2&action=$3 [QSA,L]
25
+ RewriteRule ^([-_a-zA-Z0-9]+)/([-_a-zA-Z0-9]+)/$ ?module=$1&controller=$2&action=index [QSA,L]
41
26
 
42
27
  # You can also point these error messages to a controller/action
43
28
  ErrorDocument 500 /500.html
@@ -1,6 +1,6 @@
1
- production:
1
+ development:
2
2
  adapter: mysql
3
- database: rails_production
3
+ database: rails_development
4
4
  host: localhost
5
5
  username: root
6
6
  password:
@@ -11,3 +11,10 @@ test:
11
11
  host: localhost
12
12
  username: root
13
13
  password:
14
+
15
+ production:
16
+ adapter: mysql
17
+ database: rails_production
18
+ host: localhost
19
+ username: root
20
+ password:
@@ -1,7 +1,7 @@
1
1
  #!/usr/local/bin/ruby
2
2
 
3
- require File.dirname(__FILE__) + "/../config/environments/production"
3
+ require File.dirname(__FILE__) + "/../config/environment"
4
4
  require 'dispatcher'
5
5
  require 'fcgi'
6
6
 
7
- FCGI.each_cgi { |cgi| Dispatcher.dispatch(cgi, Dispatcher::DEFAULT_SESSION_OPTIONS, File.dirname(__FILE__) + "/500.html") }
7
+ FCGI.each_cgi { |cgi| Dispatcher.dispatch(cgi) }
@@ -1,10 +1,10 @@
1
1
  #!/usr/local/bin/ruby
2
2
 
3
- require File.dirname(__FILE__) + "/../config/environments/production"
3
+ require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
4
4
 
5
5
  # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
6
6
  # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired
7
7
  require "dispatcher"
8
8
 
9
- ADDITIONAL_LOAD_PATHS.each { |dir| $:.unshift "#{File.dirname(__FILE__)}/../#{dir}" }
9
+ ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) }
10
10
  Dispatcher.dispatch
@@ -27,13 +27,9 @@
27
27
  </head>
28
28
  <body>
29
29
 
30
- <h1>Congratulations, you're on Rails!</h1>
30
+ <h1>Congratulations, you've put Ruby on Rails!</h1>
31
31
 
32
- <p>
33
- <i>You've succesfully configured your web server to point at this Rails application.</i>
34
- </p>
35
-
36
- <p>Before you move on, verify that the following conditions have been met:</p>
32
+ <p><b>Before you move on</b>, verify that the following conditions have been met:</p>
37
33
 
38
34
  <ol>
39
35
  <li>The log directory and the empty log files must be writable to the web server (<code>chmod -R 777 log</code>).
@@ -53,42 +49,22 @@
53
49
  <p>Take the following steps to get started:</p>
54
50
 
55
51
  <ol>
56
- <li>Create empty production and test databases for your application.<br/>
57
- <small>Warning: Don't point your test database at your production database, it'll destroy the latter on test runs!</small>
52
+ <li>Create empty development and test databases for your application.<br/>
53
+ <small>Recommendation: Use *_development and *_test names, such as basecamp_development and basecamp_test</small><br/>
54
+ <small>Warning: Don't point your test database at your development database, it'll destroy the latter on test runs!</small>
58
55
  <li>Edit config/database.yml with your database settings.
59
- <li>Create a new controller using the <code>script/new_controller</code> generator <br/>
60
- <small>Help: Run with no arguments for documentation</small>
61
- <li>Create a new model using the <code>script/new_model</code> generator <br/>
62
- <small>Help: Run with no arguments for documentation</small>
63
- <li>See all the tests run and fail by running <code>rake</code>.
56
+ <li>Create controllers and models using the generator in <code>script/generate</code> <br/>
57
+ <small>Help: Run the generator with no arguments for documentation</small>
58
+ <li>See all the tests run by running <code>rake</code>.
64
59
  <li>Develop your Rails application!
65
- <li>Setup FastCGI or mod_ruby to get production-level performance
60
+ <li>Setup Apache with <a href="http://www.fastcgi.com">FastCGI</a> (and <a href="http://raa.ruby-lang.org/list.rhtml?name=fcgi">Ruby bindings</a>), if you need better performance
66
61
  </ol>
67
62
 
68
63
  <p>
69
- Having problems getting up and running? First try debugging it yourself by looking at the log files. <br/> Then try the friendly Rails
70
- community on IRC (<a href="http://www.rubyonrails.org/show/IRC">howto IRC</a>). It's on FreeNET in channel #rubyonrails.
64
+ Having problems getting up and running? First try debugging it yourself by looking at the log files. <br/>
65
+ Then try the friendly Rails community <a href="http://www.rubyonrails.org">on the web</a> or <a href="http://www.rubyonrails.org/show/IRC">on IRC</a>
66
+ (<a href="irc://irc.freenode.net/#rubyonrails">FreeNode#rubyonrails</a>).
71
67
  </p>
72
68
 
73
- <div style="float: left; margin-right: 20px">
74
- <h2>Rails Online</h2>
75
-
76
- <ul>
77
- <li><a href="http://www.rubyonrails.org">Ruby on Rails</a></li>
78
- <li><a href="http://activerecord.rubyonrails.org">Active Record</a></li>
79
- <li><a href="http://actionpack.rubyonrails.org">Action Pack</a></li>
80
- </ul>
81
- </div>
82
-
83
- <div style="float: left">
84
- <h2>Beyond CGI</h2>
85
-
86
- <ul>
87
- <li><a href="http://www.fastcgi.com">FastCGI</a></li>
88
- <li><a href="http://raa.ruby-lang.org/list.rhtml?name=fcgi">FastCGI bindings for Ruby</a></li>
89
- <li><a href="http://modruby.net/en/">mod_ruby</a></li>
90
- </ul>
91
- </div>
92
-
93
69
  </body>
94
70
  </html>
@@ -0,0 +1,5 @@
1
+ ActionController::Base.consider_all_requests_local = true
2
+ ActionController::Base.reload_dependencies = true
3
+ ActiveRecord::Base.reload_associations = true
4
+
5
+ BREAKPOINT_SERVER_PORT = 42531
@@ -1,6 +1,3 @@
1
- require File.dirname(__FILE__) + "/shared"
2
-
3
- ActiveRecord::Base.logger = ActionController::Base.logger = ActionMailer::Base.logger =
4
- Logger.new(File.dirname(__FILE__) + "/../../log/production.log")
5
-
6
- ActiveRecord::Base.establish_connection(database_configurations["production"])
1
+ ActionController::Base.consider_all_requests_local = false
2
+ ActionController::Base.reload_dependencies = false
3
+ ActiveRecord::Base.reload_associations = false
@@ -1,27 +1,53 @@
1
- ADDITIONAL_LOAD_PATHS = [
2
- "app/models",
3
- "app/controllers",
4
- "app/helpers",
5
- "config",
6
- "lib",
7
- "vendor",
8
- "vendor/railties",
9
- "vendor/railties/lib",
10
- "vendor/activerecord/lib",
11
- "vendor/actionpack/lib",
12
- "vendor/actionmailer/lib"
13
- ]
14
-
15
- ADDITIONAL_LOAD_PATHS.each { |dir| $:.unshift "#{File.dirname(__FILE__)}/../../#{dir}" }
1
+ RAILS_ROOT = File.expand_path(File.dirname(__FILE__) + "/../")
2
+ RAILS_ENV = ENV['RAILS_ENV'] || 'development'
16
3
 
4
+
5
+ # Mocks first.
6
+ ADDITIONAL_LOAD_PATHS = ["#{RAILS_ROOT}/test/mocks/#{RAILS_ENV}"]
7
+
8
+ # Then model subdirectories.
9
+ ADDITIONAL_LOAD_PATHS.concat(Dir["#{RAILS_ROOT}/app/models/[_a-z]*"])
10
+
11
+ # Followed by the standard includes.
12
+ ADDITIONAL_LOAD_PATHS.concat %w(
13
+ app
14
+ app/models
15
+ app/controllers
16
+ app/helpers
17
+ config
18
+ lib
19
+ vendor
20
+ vendor/railties
21
+ vendor/railties/lib
22
+ vendor/activerecord/lib
23
+ vendor/actionpack/lib
24
+ vendor/actionmailer/lib
25
+ ).map { |dir| "#{RAILS_ROOT}/#{dir}" }
26
+
27
+ # Prepend to $LOAD_PATH
28
+ ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) }
29
+
30
+
31
+ # Require Rails libraries.
17
32
  require 'active_record'
18
33
  require 'action_controller'
19
34
  require 'action_mailer'
20
35
 
21
- require 'yaml'
22
36
 
23
- ActionController::Base.template_root = ActionMailer::Base.template_root = File.dirname(__FILE__) + '/../../app/views/'
37
+ # Environment-specific configuration.
38
+ require_dependency "environments/#{RAILS_ENV}"
39
+ ActiveRecord::Base.configurations = YAML::load(File.open("#{RAILS_ROOT}/config/database.yml"))
40
+ ActiveRecord::Base.establish_connection
41
+
42
+
43
+ # Configure defaults if the included environment did not.
44
+ RAILS_DEFAULT_LOGGER = Logger.new("#{RAILS_ROOT}/log/#{RAILS_ENV}.log")
45
+ [ActiveRecord::Base, ActionController::Base, ActionMailer::Base].each do |klass|
46
+ klass.logger ||= RAILS_DEFAULT_LOGGER
47
+ end
48
+ [ActionController::Base, ActionMailer::Base].each do |klass|
49
+ klass.template_root ||= "#{RAILS_ROOT}/app/views/"
50
+ end
51
+
24
52
 
25
- def database_configurations
26
- YAML::load(File.open(File.dirname(__FILE__) + "/../../config/database.yml"))
27
- end
53
+ # Include your app's configuration here:
@@ -1,17 +1,50 @@
1
- ADDITIONAL_LOAD_PATHS = [ "app/models", "app/controllers", "app/helpers", "config", "lib", "vendor" ]
2
- ADDITIONAL_LOAD_PATHS.each { |dir| $:.unshift "#{File.dirname(__FILE__)}/../../#{dir}" }
1
+ RAILS_ROOT = File.expand_path(File.dirname(__FILE__) + "/../")
2
+ RAILS_ENV = ENV['RAILS_ENV'] || 'development'
3
3
 
4
- require 'rubygems'
5
4
 
5
+ # Mocks first.
6
+ ADDITIONAL_LOAD_PATHS = ["#{RAILS_ROOT}/test/mocks/#{RAILS_ENV}"]
7
+
8
+ # Then model subdirectories.
9
+ ADDITIONAL_LOAD_PATHS.concat(Dir["#{RAILS_ROOT}/app/models/[_a-z]*"])
10
+
11
+ # Followed by the standard includes.
12
+ ADDITIONAL_LOAD_PATHS.concat %w(
13
+ app
14
+ app/models
15
+ app/controllers
16
+ app/helpers
17
+ config
18
+ lib
19
+ vendor
20
+ ).map { |dir| "#{RAILS_ROOT}/#{dir}" }
21
+
22
+ # Prepend to $LOAD_PATH
23
+ ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) }
24
+
25
+
26
+ # Require Rails gems.
27
+ require 'rubygems'
6
28
  require_gem 'activerecord'
7
29
  require_gem 'actionpack'
8
30
  require_gem 'actionmailer'
9
31
  require_gem 'rails'
10
32
 
11
- require 'yaml'
12
33
 
13
- ActionController::Base.template_root = ActionMailer::Base.template_root = File.dirname(__FILE__) + '/../../app/views/'
34
+ # Environment-specific configuration.
35
+ require_dependency "environments/#{RAILS_ENV}"
36
+ ActiveRecord::Base.configurations = YAML::load(File.open("#{RAILS_ROOT}/config/database.yml"))
37
+ ActiveRecord::Base.establish_connection
38
+
39
+
40
+ # Configure defaults if the included environment did not.
41
+ RAILS_DEFAULT_LOGGER = Logger.new("#{RAILS_ROOT}/log/#{RAILS_ENV}.log")
42
+ [ActiveRecord::Base, ActionController::Base, ActionMailer::Base].each do |klass|
43
+ klass.logger ||= RAILS_DEFAULT_LOGGER
44
+ end
45
+ [ActionController::Base, ActionMailer::Base].each do |klass|
46
+ klass.template_root ||= "#{RAILS_ROOT}/app/views/"
47
+ end
48
+
14
49
 
15
- def database_configurations
16
- YAML::load(File.open(File.dirname(__FILE__) + "/../../config/database.yml"))
17
- end
50
+ # Include your app's configuration here: