railties 3.1.0.rc4 → 3.1.0.rc5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data/CHANGELOG +7 -9
  2. data/bin/rails +2 -0
  3. data/guides/assets/images/rails_welcome.png +0 -0
  4. data/guides/rails_guides/generator.rb +1 -1
  5. data/guides/rails_guides/textile_extensions.rb +18 -17
  6. data/guides/source/3_0_release_notes.textile +21 -21
  7. data/guides/source/action_controller_overview.textile +1 -1
  8. data/guides/source/action_mailer_basics.textile +27 -6
  9. data/guides/source/action_view_overview.textile +6 -6
  10. data/guides/source/active_record_querying.textile +77 -7
  11. data/guides/source/active_record_validations_callbacks.textile +78 -81
  12. data/guides/source/active_support_core_extensions.textile +87 -31
  13. data/guides/source/ajax_on_rails.textile +1 -1
  14. data/guides/source/api_documentation_guidelines.textile +12 -8
  15. data/guides/source/asset_pipeline.textile +416 -0
  16. data/guides/source/association_basics.textile +2 -4
  17. data/guides/source/caching_with_rails.textile +7 -6
  18. data/guides/source/command_line.textile +78 -116
  19. data/guides/source/configuring.textile +34 -17
  20. data/guides/source/contribute.textile +1 -1
  21. data/guides/source/contributing_to_ruby_on_rails.textile +3 -3
  22. data/guides/source/debugging_rails_applications.textile +2 -2
  23. data/guides/source/form_helpers.textile +40 -51
  24. data/guides/source/getting_started.textile +641 -197
  25. data/guides/source/initialization.textile +4 -4
  26. data/guides/source/layouts_and_rendering.textile +2 -2
  27. data/guides/source/migrations.textile +114 -32
  28. data/guides/source/nested_model_forms.textile +6 -6
  29. data/guides/source/performance_testing.textile +6 -6
  30. data/guides/source/plugins.textile +23 -22
  31. data/guides/source/rails_application_templates.textile +8 -14
  32. data/guides/source/routing.textile +57 -51
  33. data/guides/source/ruby_on_rails_guides_guidelines.textile +3 -3
  34. data/guides/source/security.textile +10 -10
  35. data/guides/source/testing.textile +1 -1
  36. data/lib/rails.rb +27 -1
  37. data/lib/rails/all.rb +1 -0
  38. data/lib/rails/application.rb +4 -10
  39. data/lib/rails/application/configuration.rb +3 -12
  40. data/lib/rails/application/railties.rb +1 -1
  41. data/lib/rails/engine.rb +53 -42
  42. data/lib/rails/generators.rb +1 -1
  43. data/lib/rails/generators/app_base.rb +36 -15
  44. data/lib/rails/generators/generated_attribute.rb +1 -1
  45. data/lib/rails/generators/js/assets/assets_generator.rb +13 -0
  46. data/lib/rails/generators/js/assets/templates/javascript.js +2 -0
  47. data/lib/rails/generators/rails/app/app_generator.rb +3 -1
  48. data/lib/rails/generators/rails/app/templates/Gemfile +11 -7
  49. data/lib/rails/generators/rails/app/templates/config/application.rb +7 -3
  50. data/lib/rails/generators/rails/app/templates/config/databases/jdbc.yml +62 -0
  51. data/lib/rails/generators/rails/app/templates/config/databases/jdbcmysql.yml +3 -3
  52. data/lib/rails/generators/rails/app/templates/config/databases/jdbcpostgresql.yml +3 -12
  53. data/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml +3 -3
  54. data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +0 -3
  55. data/lib/rails/generators/rails/assets/assets_generator.rb +2 -9
  56. data/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb +12 -10
  57. data/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec +5 -2
  58. data/lib/rails/generators/rails/plugin_new/templates/Gemfile +6 -3
  59. data/lib/rails/generators/rails/plugin_new/templates/Rakefile +5 -1
  60. data/lib/rails/generators/rails/plugin_new/templates/app/views/layouts/application.html.erb.tt +14 -0
  61. data/lib/rails/generators/rails/plugin_new/templates/rails/application.rb +5 -3
  62. data/lib/rails/info.rb +4 -0
  63. data/lib/rails/paths.rb +5 -5
  64. data/lib/rails/railtie.rb +4 -4
  65. data/lib/rails/tasks.rb +0 -1
  66. data/lib/rails/tasks/documentation.rake +3 -3
  67. data/lib/rails/tasks/engine.rake +2 -0
  68. data/lib/rails/tasks/framework.rake +3 -3
  69. data/lib/rails/tasks/tmp.rake +1 -1
  70. data/lib/rails/test_unit/testing.rake +2 -2
  71. data/lib/rails/version.rb +1 -1
  72. metadata +19 -33
  73. data/lib/rails/generators/rails/assets/templates/javascript.js.coffee +0 -3
  74. data/lib/rails/tasks/assets.rake +0 -21
@@ -8,12 +8,14 @@ require 'rails/all'
8
8
  require "action_controller/railtie"
9
9
  require "action_mailer/railtie"
10
10
  require "active_resource/railtie"
11
+ <%= comment_if :skip_sprockets %> require "sprockets/railtie"
11
12
  <%= comment_if :skip_test_unit %> require "rails/test_unit/railtie"
12
13
  <% end -%>
13
14
 
14
- # If you have a Gemfile, require the gems listed there, including any gems
15
- # you've limited to :test, :development, or :production.
16
- Bundler.require(:default, Rails.env) if defined?(Bundler)
15
+ # If you have a Gemfile, require the default gems, the ones in the
16
+ # current environment and also include :assets gems if in development
17
+ # or test environments.
18
+ Bundler.require *Rails.groups(:assets) if defined?(Bundler)
17
19
 
18
20
  module <%= app_const_base %>
19
21
  class Application < Rails::Application
@@ -45,7 +47,9 @@ module <%= app_const_base %>
45
47
  # Configure sensitive parameters which will be filtered from the log file.
46
48
  config.filter_parameters += [:password]
47
49
 
50
+ <% unless options.skip_sprockets? -%>
48
51
  # Enable the asset pipeline
49
52
  config.assets.enabled = true
53
+ <% end -%>
50
54
  end
51
55
  end
@@ -0,0 +1,62 @@
1
+ # If you are using mssql, derby, hsqldb, or h2 with one of the
2
+ # ActiveRecord JDBC adapters, install the appropriate driver, e.g.,:
3
+ # gem install activerecord-jdbcmssql-adapter
4
+ #
5
+ # Configure using Gemfile:
6
+ # gem 'activerecord-jdbcmssql-adapter'
7
+ #
8
+ #development:
9
+ # adapter: mssql
10
+ # username: <%= app_name %>
11
+ # password:
12
+ # host: localhost
13
+ # database: <%= app_name %>_development
14
+ #
15
+ # Warning: The database defined as "test" will be erased and
16
+ # re-generated from your development database when you run "rake".
17
+ # Do not set this db to the same as development or production.
18
+ #
19
+ #test:
20
+ # adapter: mssql
21
+ # username: <%= app_name %>
22
+ # password:
23
+ # host: localhost
24
+ # database: <%= app_name %>_test
25
+ #
26
+ #production:
27
+ # adapter: mssql
28
+ # username: <%= app_name %>
29
+ # password:
30
+ # host: localhost
31
+ # database: <%= app_name %>_production
32
+
33
+ # If you are using oracle, db2, sybase, informix or prefer to use the plain
34
+ # JDBC adapter, configure your database setting as the example below (requires
35
+ # you to download and manually install the database vendor's JDBC driver .jar
36
+ # file). See your driver documentation for the apropriate driver class and
37
+ # connection string:
38
+
39
+ development:
40
+ adapter: jdbc
41
+ username: <%= app_name %>
42
+ password:
43
+ driver:
44
+ url: jdbc:db://localhost/<%= app_name %>_development
45
+
46
+ # Warning: The database defined as "test" will be erased and
47
+ # re-generated from your development database when you run "rake".
48
+ # Do not set this db to the same as development or production.
49
+
50
+ test:
51
+ adapter: jdbc
52
+ username: <%= app_name %>
53
+ password:
54
+ driver:
55
+ url: jdbc:db://localhost/<%= app_name %>_test
56
+
57
+ production:
58
+ adapter: jdbc
59
+ username: <%= app_name %>
60
+ password:
61
+ driver:
62
+ url: jdbc:db://localhost/<%= app_name %>_production
@@ -9,7 +9,7 @@
9
9
  # And be sure to use new-style password hashing:
10
10
  # http://dev.mysql.com/doc/refman/5.0/en/old-client.html
11
11
  development:
12
- adapter: jdbcmysql
12
+ adapter: mysql
13
13
  database: <%= app_name %>_development
14
14
  username: root
15
15
  password:
@@ -19,14 +19,14 @@ development:
19
19
  # re-generated from your development database when you run "rake".
20
20
  # Do not set this db to the same as development or production.
21
21
  test:
22
- adapter: jdbcmysql
22
+ adapter: mysql
23
23
  database: <%= app_name %>_test
24
24
  username: root
25
25
  password:
26
26
  host: localhost
27
27
 
28
28
  production:
29
- adapter: jdbcmysql
29
+ adapter: mysql
30
30
  database: <%= app_name %>_production
31
31
  username: root
32
32
  password:
@@ -1,19 +1,10 @@
1
1
  # PostgreSQL. Versions 7.4 and 8.x are supported.
2
2
  #
3
- # Install the pg driver:
4
- # gem install pg
5
- # On Mac OS X with macports:
6
- # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
7
- # On Windows:
8
- # gem install pg
9
- # Choose the win32 build.
10
- # Install PostgreSQL and put its /bin directory on your path.
11
- #
12
3
  # Configure Using Gemfile
13
4
  # gem 'activerecord-jdbcpostgresql-adapter'
14
5
 
15
6
  development:
16
- adapter: jdbcpostgresql
7
+ adapter: postgresql
17
8
  encoding: unicode
18
9
  database: <%= app_name %>_development
19
10
  username: <%= app_name %>
@@ -38,14 +29,14 @@ development:
38
29
  # re-generated from your development database when you run "rake".
39
30
  # Do not set this db to the same as development or production.
40
31
  test:
41
- adapter: jdbcpostgresql
32
+ adapter: postgresql
42
33
  encoding: unicode
43
34
  database: <%= app_name %>_test
44
35
  username: <%= app_name %>
45
36
  password:
46
37
 
47
38
  production:
48
- adapter: jdbcpostgresql
39
+ adapter: postgresql
49
40
  encoding: unicode
50
41
  database: <%= app_name %>_production
51
42
  username: <%= app_name %>
@@ -5,16 +5,16 @@
5
5
  # gem 'activerecord-jdbcsqlite3-adapter'
6
6
  #
7
7
  development:
8
- adapter: jdbcsqlite3
8
+ adapter: sqlite3
9
9
  database: db/development.sqlite3
10
10
 
11
11
  # Warning: The database defined as "test" will be erased and
12
12
  # re-generated from your development database when you run "rake".
13
13
  # Do not set this db to the same as development or production.
14
14
  test:
15
- adapter: jdbcsqlite3
15
+ adapter: sqlite3
16
16
  database: db/test.sqlite3
17
17
 
18
18
  production:
19
- adapter: jdbcsqlite3
19
+ adapter: sqlite3
20
20
  database: db/production.sqlite3
@@ -14,9 +14,6 @@
14
14
  # Compress JavaScripts and CSS
15
15
  config.assets.compress = true
16
16
 
17
- # Specify the default JavaScript compressor
18
- config.assets.js_compressor = :uglifier
19
-
20
17
  # Specifies the header that your server uses for sending files
21
18
  # (comment out if your front-end server doesn't support this)
22
19
  config.action_dispatch.x_sendfile_header = "X-Sendfile" # Use 'X-Accel-Redirect' for nginx
@@ -7,21 +7,14 @@ module Rails
7
7
  class_option :javascript_engine, :desc => "Engine for JavaScripts"
8
8
  class_option :stylesheet_engine, :desc => "Engine for Stylesheets"
9
9
 
10
- def create_javascript_files
11
- return unless options.javascripts?
12
- copy_file "javascript.#{javascript_extension}",
13
- File.join('app/assets/javascripts', class_path, "#{asset_name}.#{javascript_extension}")
14
- end
15
-
16
10
  protected
17
11
 
18
12
  def asset_name
19
13
  file_name
20
14
  end
21
15
 
22
- def javascript_extension
23
- options.javascript_engine.present? ?
24
- "js.#{options.javascript_engine}" : "js"
16
+ hook_for :javascript_engine do |javascript_engine|
17
+ invoke javascript_engine, [name] if options[:javascripts]
25
18
  end
26
19
 
27
20
  hook_for :stylesheet_engine do |stylesheet_engine|
@@ -11,15 +11,15 @@ module Rails
11
11
  def app
12
12
  if mountable?
13
13
  directory "app"
14
- template "#{app_templates_dir}/app/views/layouts/application.html.erb.tt",
14
+ template "app/views/layouts/application.html.erb.tt",
15
15
  "app/views/layouts/#{name}/application.html.erb"
16
- empty_directory_with_gitkeep "app/assets/images"
16
+ empty_directory_with_gitkeep "app/assets/images/#{name}"
17
17
  elsif full?
18
18
  empty_directory_with_gitkeep "app/models"
19
19
  empty_directory_with_gitkeep "app/controllers"
20
20
  empty_directory_with_gitkeep "app/views"
21
21
  empty_directory_with_gitkeep "app/helpers"
22
- empty_directory_with_gitkeep "app/assets/images"
22
+ empty_directory_with_gitkeep "app/assets/images/#{name}"
23
23
  end
24
24
  end
25
25
 
@@ -108,9 +108,9 @@ task :default => :test
108
108
  def stylesheets
109
109
  if mountable?
110
110
  copy_file "#{app_templates_dir}/app/assets/stylesheets/application.css",
111
- "app/assets/stylesheets/application.css"
111
+ "app/assets/stylesheets/#{name}/application.css"
112
112
  elsif full?
113
- empty_directory_with_gitkeep "app/assets/stylesheets"
113
+ empty_directory_with_gitkeep "app/assets/stylesheets/#{name}"
114
114
  end
115
115
  end
116
116
 
@@ -118,14 +118,16 @@ task :default => :test
118
118
  return if options.skip_javascript?
119
119
 
120
120
  if mountable?
121
- copy_file "#{app_templates_dir}/app/assets/javascripts/application.js.tt",
122
- "app/assets/javascripts/application.js"
121
+ template "#{app_templates_dir}/app/assets/javascripts/application.js.tt",
122
+ "app/assets/javascripts/#{name}/application.js"
123
123
  elsif full?
124
- empty_directory_with_gitkeep "app/assets/javascripts"
124
+ empty_directory_with_gitkeep "app/assets/javascripts/#{name}"
125
125
  end
126
126
  end
127
127
 
128
128
  def script(force = false)
129
+ return unless full?
130
+
129
131
  directory "script", :force => force do |content|
130
132
  "#{shebang}\n" + content
131
133
  end
@@ -202,7 +204,7 @@ task :default => :test
202
204
  end
203
205
 
204
206
  def create_test_dummy_files
205
- return if options[:skip_test_unit]
207
+ return if options[:skip_test_unit] && options[:dummy_path] == 'test/dummy'
206
208
  create_dummy_app
207
209
  end
208
210
 
@@ -258,7 +260,7 @@ task :default => :test
258
260
  elsif RESERVED_NAMES.include?(name)
259
261
  raise Error, "Invalid plugin name #{name}. Please give a name which does not match one of the reserved rails words."
260
262
  elsif Object.const_defined?(camelized)
261
- raise Error, "Invalid plugin name #{name}, constant #{camelized} is already in use. Please choose another application name."
263
+ raise Error, "Invalid plugin name #{name}, constant #{camelized} is already in use. Please choose another plugin name."
262
264
  end
263
265
  end
264
266
 
@@ -4,6 +4,9 @@ Gem::Specification.new do |s|
4
4
  s.name = "<%= name %>"
5
5
  s.summary = "Insert <%= camelized %> summary."
6
6
  s.description = "Insert <%= camelized %> description."
7
- s.files = Dir["lib/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"]
7
+ s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"]
8
+ <% unless options.skip_test_unit? -%>
9
+ s.test_files = Dir["test/**/*"]
10
+ <% end -%>
8
11
  s.version = "0.0.1"
9
- end
12
+ end
@@ -6,6 +6,9 @@ source "http://rubygems.org"
6
6
  <%= database_gemfile_entry -%>
7
7
  <% end -%>
8
8
 
9
- if RUBY_VERSION < '1.9'
10
- gem "ruby-debug", ">= 0.10.3"
11
- end
9
+ <% if mountable? -%>
10
+ <%= javascript_gemfile_entry -%>
11
+ <% end -%>
12
+
13
+ # To use debugger
14
+ # <%= ruby_debugger_gemfile_entry %>
@@ -15,7 +15,7 @@ end
15
15
  RDoc::Task.new(:rdoc) do |rdoc|
16
16
  rdoc.rdoc_dir = 'rdoc'
17
17
  rdoc.title = '<%= camelized %>'
18
- rdoc.options << '--line-numbers' << '--inline-source'
18
+ rdoc.options << '--line-numbers'
19
19
  rdoc.rdoc_files.include('README.rdoc')
20
20
  rdoc.rdoc_files.include('lib/**/*.rb')
21
21
  end
@@ -24,3 +24,7 @@ end
24
24
  APP_RAKEFILE = File.expand_path("../<%= dummy_path -%>/Rakefile", __FILE__)
25
25
  load 'rails/tasks/engine.rake'
26
26
  <% end %>
27
+ <% unless options[:skip_gemspec] -%>
28
+
29
+ Bundler::GemHelper.install_tasks
30
+ <% end %>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title><%= camelized %></title>
5
+ <%%= stylesheet_link_tag "<%= name %>/application" %>
6
+ <%%= javascript_include_tag "<%= name %>/application" %>
7
+ <%%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -1,13 +1,15 @@
1
1
  require File.expand_path('../boot', __FILE__)
2
2
 
3
- <% unless options[:skip_active_record] -%>
3
+ <% if include_all_railties? -%>
4
4
  require 'rails/all'
5
5
  <% else -%>
6
- # require "active_record/railtie"
6
+ # Pick the frameworks you want:
7
+ <%= comment_if :skip_active_record %> require "active_record/railtie"
7
8
  require "action_controller/railtie"
8
9
  require "action_mailer/railtie"
9
10
  require "active_resource/railtie"
10
- require "rails/test_unit/railtie"
11
+ <%= comment_if :skip_sprockets %> require "sprockets/railtie"
12
+ <%= comment_if :skip_test_unit %> require "rails/test_unit/railtie"
11
13
  <% end -%>
12
14
 
13
15
  Bundler.require
@@ -78,6 +78,10 @@ module Rails
78
78
  Rails::VERSION::STRING
79
79
  end
80
80
 
81
+ property 'JavaScript Runtime' do
82
+ ExecJS.runtime.name
83
+ end
84
+
81
85
  # Versions of each Rails framework (Active Record, Action Pack,
82
86
  # Active Resource, Action Mailer, and Active Support).
83
87
  frameworks.each do |framework|
@@ -7,8 +7,8 @@ module Rails
7
7
  match = id.to_s.match(/^(.*)=$/)
8
8
  full = [@current, $1 || id].compact.join("/")
9
9
 
10
- ActiveSupport::Deprecation.warn 'config.paths.app.controller API is deprecated in ' <<
11
- 'favor of config.paths["app/controller"] API.'
10
+ ActiveSupport::Deprecation.warn 'Accessing paths using dot style as in `config.paths.app.controller` is deprecated. Please use ' <<
11
+ '`config.paths["app/controller"]` style instead.'
12
12
 
13
13
  if match || args.any?
14
14
  @root[full] = Path.new(@root, full, *args)
@@ -49,8 +49,8 @@ module Rails
49
49
  # root.add "config/routes", :with => "config/routes.rb"
50
50
  # root["config/routes"].inspect # => ["config/routes.rb"]
51
51
  #
52
- # #add also accepts the following options as argument: eager_load, autoload,
53
- # autoload_once and glob.
52
+ # The #add method accepts the following options as arguments:
53
+ # eager_load, autoload, autoload_once and glob.
54
54
  #
55
55
  # Finally, the Path object also provides a few helpers:
56
56
  #
@@ -179,7 +179,7 @@ module Rails
179
179
  path = File.expand_path(p, @root.path)
180
180
 
181
181
  if @glob
182
- result.concat Dir[File.join(path, @glob)]
182
+ result.concat Dir[File.join(path, @glob)].sort
183
183
  else
184
184
  result << path
185
185
  end
@@ -83,7 +83,7 @@ module Rails
83
83
  # == Loading rake tasks and generators
84
84
  #
85
85
  # If your railtie has rake tasks, you can tell Rails to load them through the method
86
- # rake tasks:
86
+ # rake_tasks:
87
87
  #
88
88
  # class MyRailtie < Rails::Railtie
89
89
  # rake_tasks do
@@ -173,11 +173,11 @@ module Rails
173
173
  def eager_load!
174
174
  end
175
175
 
176
- def load_console(app)
176
+ def load_console(app=self)
177
177
  self.class.console.each { |block| block.call(app) }
178
178
  end
179
179
 
180
- def load_tasks(app)
180
+ def load_tasks(app=self)
181
181
  extend Rake::DSL if defined? Rake::DSL
182
182
  self.class.rake_tasks.each { |block| block.call(app) }
183
183
 
@@ -189,7 +189,7 @@ module Rails
189
189
  end
190
190
  end
191
191
 
192
- def load_generators(app)
192
+ def load_generators(app=self)
193
193
  self.class.generators.each { |block| block.call(app) }
194
194
  end
195
195
  end
@@ -3,7 +3,6 @@ $VERBOSE = nil
3
3
  # Load Rails rakefile extensions
4
4
  %w(
5
5
  annotations
6
- assets
7
6
  documentation
8
7
  framework
9
8
  log
@@ -47,7 +47,7 @@ namespace :doc do
47
47
  rdoc.rdoc_dir = 'doc/app'
48
48
  rdoc.template = ENV['template'] if ENV['template']
49
49
  rdoc.title = ENV['title'] || "Rails Application Documentation"
50
- rdoc.options << '--line-numbers' << '--inline-source'
50
+ rdoc.options << '--line-numbers'
51
51
  rdoc.options << '--charset' << 'utf-8'
52
52
  rdoc.rdoc_files.include('doc/README_FOR_APP')
53
53
  rdoc.rdoc_files.include('app/**/*.rb')
@@ -60,7 +60,7 @@ namespace :doc do
60
60
  rdoc.rdoc_dir = 'doc/api'
61
61
  rdoc.template = "#{ENV['template']}.rb" if ENV['template']
62
62
  rdoc.title = "Rails Framework Documentation"
63
- rdoc.options << '--line-numbers' << '--inline-source'
63
+ rdoc.options << '--line-numbers'
64
64
  rdoc.rdoc_files.include('README')
65
65
 
66
66
  gem_path('actionmailer') do |actionmailer|
@@ -133,7 +133,7 @@ namespace :doc do
133
133
  files = Rake::FileList.new
134
134
  options << "-o doc/plugins/#{plugin}"
135
135
  options << "--title '#{plugin.titlecase} Plugin Documentation'"
136
- options << '--line-numbers' << '--inline-source'
136
+ options << '--line-numbers'
137
137
  options << '--charset' << 'utf-8'
138
138
  options << '-T html'
139
139