railties 3.2.8 → 3.2.9.rc1

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,10 +17,132 @@ If you're upgrading an existing application, it's a great idea to have good test
17
17
 
18
18
  h4. Rails 3.1 requires at least Ruby 1.8.7
19
19
 
20
+ If your application is currently on any version of Rails older than 3.0.x, you should upgrade to Rails 3.0 before attempting an update to Rails 3.1.
21
+
22
+ The following changes are meant for upgrading your application to Rails 3.1.3, the latest 3.1.x version of Rails.
23
+
24
+ h4. Ruby
25
+
20
26
  Rails 3.1 requires Ruby 1.8.7 or higher. Support for all of the previous Ruby versions has been dropped officially and you should upgrade as early as possible. Rails 3.1 is also compatible with Ruby 1.9.2.
21
27
 
22
28
  TIP: Note that Ruby 1.8.7 p248 and p249 have marshaling bugs that crash Rails. Ruby Enterprise Edition have these fixed since release 1.8.7-2010.02 though. On the 1.9 front, Ruby 1.9.1 is not usable because it outright segfaults, so if you want to use 1.9.x jump on 1.9.2 for smooth sailing.
23
29
 
30
+ h4. Gemfile
31
+
32
+ Make the following changes to your +Gemfile+.
33
+
34
+ <ruby>
35
+ gem 'rails', '= 3.1.3'
36
+ gem 'mysql2'
37
+
38
+ # Needed for the new asset pipeline
39
+ group :assets do
40
+ gem 'sass-rails', "~> 3.1.5"
41
+ gem 'coffee-rails', "~> 3.1.1"
42
+ gem 'uglifier', ">= 1.0.3"
43
+ end
44
+
45
+ # jQuery is the default JavaScript library in Rails 3.1
46
+ gem 'jquery-rails'
47
+ </ruby>
48
+
49
+ h4. config/application.rb
50
+
51
+ The asset pipeline requires the following additions:
52
+
53
+ <ruby>
54
+ config.assets.enabled = true
55
+ config.assets.version = '1.0'
56
+ </ruby>
57
+
58
+ If your application is using an "/assets" route for a resource you may want change the prefix used for assets to avoid conflicts:
59
+
60
+ <ruby>
61
+ # Defaults to '/assets'
62
+ config.assets.prefix = '/asset-files'
63
+ </ruby>
64
+
65
+ h4. config/environments/development.rb
66
+
67
+ Remove the RJS setting <tt>config.action_view.debug_rjs = true</tt>.
68
+
69
+ Add these settings if you enable the asset pipeline:
70
+
71
+ <ruby>
72
+ # Do not compress assets
73
+ config.assets.compress = false
74
+
75
+ # Expands the lines which load the assets
76
+ config.assets.debug = true
77
+ </ruby>
78
+
79
+ h4. config/environments/production.rb
80
+
81
+ Again, most of the changes below are for the asset pipeline. You can read more about these in the "Asset Pipeline":asset_pipeline.html guide.
82
+
83
+ <ruby>
84
+ # Compress JavaScripts and CSS
85
+ config.assets.compress = true
86
+
87
+ # Don't fallback to assets pipeline if a precompiled asset is missed
88
+ config.assets.compile = false
89
+
90
+ # Generate digests for assets URLs
91
+ config.assets.digest = true
92
+
93
+ # Defaults to Rails.root.join("public/assets")
94
+ # config.assets.manifest = YOUR_PATH
95
+
96
+ # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
97
+ # config.assets.precompile += %w( search.js )
98
+
99
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
100
+ # config.force_ssl = true
101
+ </ruby>
102
+
103
+ h4. config/environments/test.rb
104
+
105
+ You can help test performance with these additions to your test environment:
106
+
107
+ <ruby>
108
+ # Configure static asset server for tests with Cache-Control for performance
109
+ config.serve_static_assets = true
110
+ config.static_cache_control = "public, max-age=3600"
111
+ </ruby>
112
+
113
+ h4. config/initializers/wrap_parameters.rb
114
+
115
+ Add this file with the following contents, if you wish to wrap parameters into a nested hash. This is on by default in new applications.
116
+
117
+ <ruby>
118
+ # Be sure to restart your server when you modify this file.
119
+ # This file contains settings for ActionController::ParamsWrapper which
120
+ # is enabled by default.
121
+
122
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
123
+ ActiveSupport.on_load(:action_controller) do
124
+ wrap_parameters :format => [:json]
125
+ end
126
+
127
+ # Disable root element in JSON by default.
128
+ ActiveSupport.on_load(:active_record) do
129
+ self.include_root_in_json = false
130
+ end
131
+ </ruby>
132
+
133
+ h4. config/initializers/session_store.rb
134
+
135
+ You need to change your session key to something new, or remove all sessions:
136
+
137
+ <ruby>
138
+ # in config/initializers/session_store.rb
139
+ AppName::Application.config.session_store :cookie_store, :key => 'SOMETHINGNEW'
140
+ </ruby>
141
+
142
+ or
143
+
144
+ <tt>$ rake db:sessions:clear</tt>
145
+
24
146
  h3. Creating a Rails 3.1 application
25
147
 
26
148
  <shell>
@@ -318,6 +318,31 @@ Rails follows a simple set of coding style conventions.
318
318
 
319
319
  The above are guidelines -- please use your best judgment in using them.
320
320
 
321
+ h4. Updating the CHANGELOG
322
+
323
+ The CHANGELOG is an important part of every release. It keeps the list of changes for every Rails version.
324
+
325
+ You should add an entry to the CHANGELOG of the framework that you modified if you're adding or removing a feature, commiting a bug fix or adding deprecation notices. Refactorings and documentation changes generally should not go to the CHANGELOG.
326
+
327
+ A CHANGELOG entry should summarize what was changed and should end with author's name. You can use multiple lines if you need more space and you can attach code examples indented with 4 spaces. If a change is related to a specific issue, you should attach issue's number. Here is an example CHANGELOG entry:
328
+
329
+ <plain>
330
+ * Summary of a change that briefly describes what was changed. You can use multiple
331
+ lines and wrap them at around 80 characters. Code examples are ok, too, if needed:
332
+
333
+ class Foo
334
+ def bar
335
+ puts 'baz'
336
+ end
337
+ end
338
+
339
+ You can continue after the code example and you can attach issue number. GH#1234
340
+
341
+ * Your Name *
342
+ </plain>
343
+
344
+ Your name can be added directly after the last word if you don't provide any code examples or don't need multiple paragraphs. Otherwise, it's best to make as a new paragraph.
345
+
321
346
  h4. Sanity Check
322
347
 
323
348
  You should not be the only person who looks at the code before you submit it. You know at least one other Rails developer, right? Show them what you’re doing and ask for feedback. Doing this in private before you push a patch out publicly is the “smoke test” for a patch: if you can’t convince one other developer of the beauty of your code, you’re unlikely to convince the core team either.
@@ -221,7 +221,7 @@ h3. Creating a New Rails Project
221
221
 
222
222
  The best way to use this guide is to follow each step as it happens, no code or
223
223
  step needed to make this example application has been left out, so you can
224
- literally follow along step by step. You can get the complete code "here":https://github.com/lifo/docrails/tree/master/railties/guides/code/getting_started.
224
+ literally follow along step by step. You can get the complete code "here":https://github.com/rails/rails/tree/3-2-stable/railties/guides/code/getting_started.
225
225
 
226
226
  By following along with this guide, you'll create a Rails project called <tt>blog</tt>, a
227
227
  (very) simple weblog. Before you can start building the application, you need to
@@ -232,6 +232,8 @@ module Rails
232
232
  end
233
233
 
234
234
  def default_middleware_stack
235
+ require 'action_controller/railtie'
236
+
235
237
  ActionDispatch::MiddlewareStack.new.tap do |middleware|
236
238
  if rack_cache = config.action_controller.perform_caching && config.action_dispatch.rack_cache
237
239
  require "action_dispatch/http/rack_cache"
@@ -138,13 +138,13 @@ module Rails
138
138
  if options.dev?
139
139
  <<-GEMFILE.strip_heredoc
140
140
  gem 'rails', :path => '#{Rails::Generators::RAILS_DEV_PATH}'
141
- gem 'journey', :git => 'git://github.com/rails/journey.git'
141
+ gem 'journey', :git => 'git://github.com/rails/journey.git', :branch => '1-0-stable'
142
142
  gem 'arel', :git => 'git://github.com/rails/arel.git', :branch => '3-0-stable'
143
143
  GEMFILE
144
144
  elsif options.edge?
145
145
  <<-GEMFILE.strip_heredoc
146
146
  gem 'rails', :git => 'git://github.com/rails/rails.git', :branch => '3-2-stable'
147
- gem 'journey', :git => 'git://github.com/rails/journey.git'
147
+ gem 'journey', :git => 'git://github.com/rails/journey.git', :branch => '1-0-stable'
148
148
  gem 'arel', :git => 'git://github.com/rails/arel.git', :branch => '3-0-stable'
149
149
  GEMFILE
150
150
  else
@@ -1,13 +1,50 @@
1
1
  module Rails
2
2
  module Generators
3
3
  class ResourceRouteGenerator < NamedBase
4
+
5
+ # Properly nests namespaces passed into a generator
6
+ #
7
+ # $ rails generate resource admin/users/products
8
+ #
9
+ # should give you
10
+ #
11
+ # namespace :admin do
12
+ # namespace :users
13
+ # resources :products
14
+ # end
15
+ # end
4
16
  def add_resource_route
5
17
  return if options[:actions].present?
6
- route_config = regular_class_path.collect{ |namespace| "namespace :#{namespace} do " }.join(" ")
7
- route_config << "resources :#{file_name.pluralize}"
8
- route_config << " end" * regular_class_path.size
9
- route route_config
18
+
19
+ # iterates over all namespaces and opens up blocks
20
+ regular_class_path.each_with_index do |namespace, index|
21
+ write("namespace :#{namespace} do", index + 1)
22
+ end
23
+
24
+ # inserts the primary resource
25
+ write("resources :#{file_name.pluralize}", route_length + 1)
26
+
27
+ # ends blocks
28
+ regular_class_path.each_index do |index|
29
+ write("end", route_length - index)
30
+ end
31
+
32
+ # route prepends two spaces onto the front of the string that is passed, this corrects that
33
+ route route_string[2..-1]
10
34
  end
35
+
36
+ private
37
+ def route_string
38
+ @route_string ||= ""
39
+ end
40
+
41
+ def write(str, indent)
42
+ route_string << "#{" " * indent}#{str}\n"
43
+ end
44
+
45
+ def route_length
46
+ regular_class_path.length
47
+ end
11
48
  end
12
49
  end
13
50
  end
@@ -87,14 +87,15 @@ module Rails
87
87
  protected
88
88
 
89
89
  def filter_by(constraint)
90
- all = []
90
+ yes = []
91
+ no = []
92
+
91
93
  all_paths.each do |path|
92
- if path.send(constraint)
93
- paths = path.existent
94
- paths -= path.children.map { |p| p.send(constraint) ? [] : p.existent }.flatten
95
- all.concat(paths)
96
- end
94
+ paths = path.existent + path.existent_base_paths
95
+ path.send(constraint) ? yes.concat(paths) : no.concat(paths)
97
96
  end
97
+
98
+ all = yes - no
98
99
  all.uniq!
99
100
  all
100
101
  end
@@ -194,6 +195,10 @@ module Rails
194
195
  expanded.select { |d| File.directory?(d) }
195
196
  end
196
197
 
198
+ def existent_base_paths
199
+ map { |p| File.expand_path(p, @root.path) }.select{ |f| File.exist? f }
200
+ end
201
+
197
202
  alias to_a expanded
198
203
 
199
204
  private
@@ -3,35 +3,48 @@ require 'active_support/core_ext/object/blank'
3
3
 
4
4
  module Rails
5
5
  module Rack
6
- # Log the request started and flush all loggers after it.
6
+ # Sets log tags, logs the request, calls the app, and flushes the logs.
7
7
  class Logger < ActiveSupport::LogSubscriber
8
- def initialize(app, tags=nil)
9
- @app, @tags = app, tags.presence
8
+ def initialize(app, taggers = nil)
9
+ @app, @taggers = app, taggers || []
10
10
  end
11
11
 
12
12
  def call(env)
13
- if @tags
14
- Rails.logger.tagged(compute_tags(env)) { call_app(env) }
13
+ request = ActionDispatch::Request.new(env)
14
+
15
+ if Rails.logger.respond_to?(:tagged)
16
+ Rails.logger.tagged(compute_tags(request)) { call_app(request, env) }
15
17
  else
16
- call_app(env)
18
+ call_app(request, env)
17
19
  end
18
20
  end
19
21
 
20
22
  protected
21
23
 
22
- def call_app(env)
23
- request = ActionDispatch::Request.new(env)
24
- path = request.filtered_path
25
- Rails.logger.info "\n\nStarted #{request.request_method} \"#{path}\" for #{request.ip} at #{Time.now.to_default_s}"
24
+ def call_app(request, env)
25
+ # Put some space between requests in development logs.
26
+ if Rails.env.development?
27
+ Rails.logger.info ''
28
+ Rails.logger.info ''
29
+ end
30
+
31
+ Rails.logger.info started_request_message(request)
26
32
  @app.call(env)
27
33
  ensure
28
34
  ActiveSupport::LogSubscriber.flush_all!
29
35
  end
30
36
 
31
- def compute_tags(env)
32
- request = ActionDispatch::Request.new(env)
37
+ # Started GET "/session/new" for 127.0.0.1 at 2012-09-26 14:51:42 -0700
38
+ def started_request_message(request)
39
+ 'Started %s "%s" for %s at %s' % [
40
+ request.request_method,
41
+ request.filtered_path,
42
+ request.ip,
43
+ Time.now.to_default_s ]
44
+ end
33
45
 
34
- @tags.collect do |tag|
46
+ def compute_tags(request)
47
+ @taggers.collect do |tag|
35
48
  case tag
36
49
  when Proc
37
50
  tag.call(request)
@@ -2,7 +2,7 @@ if RUBY_VERSION < '1.8.7'
2
2
  desc = defined?(RUBY_DESCRIPTION) ? RUBY_DESCRIPTION : "ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE})"
3
3
  abort <<-end_message
4
4
 
5
- Rails 3 requires Ruby 1.8.7 or 1.9.2.
5
+ Rails 3 requires Ruby 1.8.7 or >= 1.9.2.
6
6
 
7
7
  You're running
8
8
  #{desc}
@@ -14,7 +14,7 @@ elsif RUBY_VERSION > '1.9' and RUBY_VERSION < '1.9.2'
14
14
  $stderr.puts <<-end_message
15
15
 
16
16
  Rails 3 doesn't officially support Ruby 1.9.1 since recent stable
17
- releases have segfaulted the test suite. Please upgrade to Ruby 1.9.2.
17
+ releases have segfaulted the test suite. Please upgrade to Ruby 1.9.2 or later.
18
18
 
19
19
  You're running
20
20
  #{RUBY_DESCRIPTION}
@@ -2,8 +2,8 @@ module Rails
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 3
4
4
  MINOR = 2
5
- TINY = 8
6
- PRE = nil
5
+ TINY = 9
6
+ PRE = "rc1"
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
9
9
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: railties
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.8
5
- prerelease:
4
+ version: 3.2.9.rc1
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - David Heinemeier Hansson
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-09 00:00:00.000000000 Z
12
+ date: 2012-10-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -88,7 +88,7 @@ dependencies:
88
88
  requirements:
89
89
  - - '='
90
90
  - !ruby/object:Gem::Version
91
- version: 3.2.8
91
+ version: 3.2.9.rc1
92
92
  type: :runtime
93
93
  prerelease: false
94
94
  version_requirements: !ruby/object:Gem::Requirement
@@ -96,7 +96,7 @@ dependencies:
96
96
  requirements:
97
97
  - - '='
98
98
  - !ruby/object:Gem::Version
99
- version: 3.2.8
99
+ version: 3.2.9.rc1
100
100
  - !ruby/object:Gem::Dependency
101
101
  name: actionpack
102
102
  requirement: !ruby/object:Gem::Requirement
@@ -104,7 +104,7 @@ dependencies:
104
104
  requirements:
105
105
  - - '='
106
106
  - !ruby/object:Gem::Version
107
- version: 3.2.8
107
+ version: 3.2.9.rc1
108
108
  type: :runtime
109
109
  prerelease: false
110
110
  version_requirements: !ruby/object:Gem::Requirement
@@ -112,7 +112,7 @@ dependencies:
112
112
  requirements:
113
113
  - - '='
114
114
  - !ruby/object:Gem::Version
115
- version: 3.2.8
115
+ version: 3.2.9.rc1
116
116
  description: ! 'Rails internals: application bootup, plugins, generators, and rake
117
117
  tasks.'
118
118
  email: david@loudthinking.com
@@ -631,12 +631,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
631
631
  required_rubygems_version: !ruby/object:Gem::Requirement
632
632
  none: false
633
633
  requirements:
634
- - - ! '>='
634
+ - - ! '>'
635
635
  - !ruby/object:Gem::Version
636
- version: '0'
637
- segments:
638
- - 0
639
- hash: 3497070782119272411
636
+ version: 1.3.1
640
637
  requirements: []
641
638
  rubyforge_project:
642
639
  rubygems_version: 1.8.24