rails 4.0.0 → 4.2.11.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +30 -23
- data/guides/CHANGELOG.md +108 -6
- data/guides/Rakefile +21 -6
- data/guides/assets/images/akshaysurve.jpg +0 -0
- data/guides/assets/images/edge_badge.png +0 -0
- data/guides/assets/images/feature_tile.gif +0 -0
- data/guides/assets/images/footer_tile.gif +0 -0
- data/guides/assets/images/fxn.png +0 -0
- data/guides/assets/images/getting_started/article_with_comments.png +0 -0
- data/guides/assets/images/getting_started/challenge.png +0 -0
- data/guides/assets/images/getting_started/confirm_dialog.png +0 -0
- data/guides/assets/images/getting_started/forbidden_attributes_for_new_article.png +0 -0
- data/guides/assets/images/getting_started/form_with_errors.png +0 -0
- data/guides/assets/images/getting_started/index_action_with_edit_link.png +0 -0
- data/guides/assets/images/getting_started/new_article.png +0 -0
- data/guides/assets/images/getting_started/rails_welcome.png +0 -0
- data/guides/assets/images/getting_started/routing_error_no_controller.png +0 -0
- data/guides/assets/images/getting_started/routing_error_no_route_matches.png +0 -0
- data/guides/assets/images/getting_started/show_action_for_articles.png +0 -0
- data/guides/assets/images/getting_started/template_is_missing_articles_new.png +0 -0
- data/guides/assets/images/getting_started/unknown_action_create_for_articles.png +0 -0
- data/guides/assets/images/getting_started/unknown_action_new_for_articles.png +0 -0
- data/guides/assets/images/header_tile.gif +0 -0
- data/guides/assets/images/icons/README +1 -1
- data/guides/assets/images/icons/callouts/11.png +0 -0
- data/guides/assets/images/icons/callouts/12.png +0 -0
- data/guides/assets/images/icons/callouts/13.png +0 -0
- data/guides/assets/images/icons/callouts/15.png +0 -0
- data/guides/assets/images/icons/caution.png +0 -0
- data/guides/assets/images/icons/example.png +0 -0
- data/guides/assets/images/radar.png +0 -0
- data/guides/assets/images/rails4_features.png +0 -0
- data/guides/assets/images/rails_guides_kindle_cover.jpg +0 -0
- data/guides/assets/images/vijaydev.jpg +0 -0
- data/guides/assets/javascripts/guides.js +36 -34
- data/guides/assets/stylesheets/main.css +6 -2
- data/guides/assets/stylesheets/print.css +1 -1
- data/guides/bug_report_templates/action_controller_gem.rb +47 -0
- data/guides/bug_report_templates/action_controller_master.rb +54 -0
- data/guides/bug_report_templates/active_record_gem.rb +5 -2
- data/guides/bug_report_templates/active_record_master.rb +3 -2
- data/guides/bug_report_templates/generic_gem.rb +15 -0
- data/guides/bug_report_templates/generic_master.rb +26 -0
- data/guides/rails_guides.rb +23 -4
- data/guides/rails_guides/generator.rb +1 -1
- data/guides/rails_guides/helpers.rb +4 -2
- data/guides/rails_guides/levenshtein.rb +27 -21
- data/guides/rails_guides/markdown.rb +11 -7
- data/guides/rails_guides/markdown/renderer.rb +1 -1
- data/guides/source/2_2_release_notes.md +3 -3
- data/guides/source/2_3_release_notes.md +12 -12
- data/guides/source/3_0_release_notes.md +10 -13
- data/guides/source/3_1_release_notes.md +7 -4
- data/guides/source/3_2_release_notes.md +17 -14
- data/guides/source/4_0_release_notes.md +110 -54
- data/guides/source/4_1_release_notes.md +730 -0
- data/guides/source/4_2_release_notes.md +877 -0
- data/guides/source/_license.html.erb +1 -1
- data/guides/source/_welcome.html.erb +6 -2
- data/guides/source/action_controller_overview.md +223 -57
- data/guides/source/action_mailer_basics.md +129 -76
- data/guides/source/action_view_overview.md +247 -246
- data/guides/source/active_job_basics.md +339 -0
- data/guides/source/active_model_basics.md +374 -20
- data/guides/source/active_record_basics.md +46 -45
- data/guides/source/active_record_callbacks.md +83 -28
- data/guides/source/{migrations.md → active_record_migrations.md} +191 -275
- data/guides/source/active_record_postgresql.md +433 -0
- data/guides/source/active_record_querying.md +382 -300
- data/guides/source/active_record_validations.md +64 -55
- data/guides/source/active_support_core_extensions.md +229 -187
- data/guides/source/active_support_instrumentation.md +23 -22
- data/guides/source/api_documentation_guidelines.md +167 -15
- data/guides/source/asset_pipeline.md +768 -294
- data/guides/source/association_basics.md +188 -96
- data/guides/source/autoloading_and_reloading_constants.md +1311 -0
- data/guides/source/caching_with_rails.md +45 -11
- data/guides/source/command_line.md +96 -65
- data/guides/source/configuring.md +404 -70
- data/guides/source/contributing_to_ruby_on_rails.md +270 -130
- data/guides/source/credits.html.erb +7 -3
- data/guides/source/debugging_rails_applications.md +471 -284
- data/guides/source/development_dependencies_install.md +115 -21
- data/guides/source/documents.yaml +31 -9
- data/guides/source/engines.md +737 -291
- data/guides/source/form_helpers.md +137 -89
- data/guides/source/generators.md +60 -28
- data/guides/source/getting_started.md +1007 -596
- data/guides/source/i18n.md +178 -96
- data/guides/source/index.html.erb +2 -1
- data/guides/source/initialization.md +248 -104
- data/guides/source/kindle/toc.html.erb +1 -1
- data/guides/source/layout.html.erb +14 -22
- data/guides/source/layouts_and_rendering.md +78 -46
- data/guides/source/maintenance_policy.md +78 -0
- data/guides/source/nested_model_forms.md +10 -7
- data/guides/source/plugins.md +66 -57
- data/guides/source/rails_application_templates.md +49 -12
- data/guides/source/rails_on_rack.md +50 -60
- data/guides/source/routing.md +190 -139
- data/guides/source/ruby_on_rails_guides_guidelines.md +12 -13
- data/guides/source/security.md +134 -83
- data/guides/source/testing.md +322 -200
- data/guides/source/upgrading_ruby_on_rails.md +834 -37
- data/guides/source/working_with_javascript_in_rails.md +36 -26
- data/guides/w3c_validator.rb +2 -0
- metadata +93 -116
- data/guides/assets/images/getting_started/forbidden_attributes_for_new_post.png +0 -0
- data/guides/assets/images/getting_started/new_post.png +0 -0
- data/guides/assets/images/getting_started/post_with_comments.png +0 -0
- data/guides/assets/images/getting_started/show_action_for_posts.png +0 -0
- data/guides/assets/images/getting_started/template_is_missing_posts_new.png +0 -0
- data/guides/assets/images/getting_started/undefined_method_post_path.png +0 -0
- data/guides/assets/images/getting_started/unknown_action_create_for_posts.png +0 -0
- data/guides/assets/images/getting_started/unknown_action_new_for_posts.png +0 -0
- data/guides/assets/images/jaimeiniesta.jpg +0 -0
- data/guides/code/getting_started/Gemfile +0 -43
- data/guides/code/getting_started/Gemfile.lock +0 -150
- data/guides/code/getting_started/README.rdoc +0 -28
- data/guides/code/getting_started/Rakefile +0 -6
- data/guides/code/getting_started/app/assets/javascripts/application.js +0 -16
- data/guides/code/getting_started/app/assets/javascripts/comments.js.coffee +0 -3
- data/guides/code/getting_started/app/assets/javascripts/posts.js.coffee +0 -3
- data/guides/code/getting_started/app/assets/javascripts/welcome.js.coffee +0 -3
- data/guides/code/getting_started/app/assets/stylesheets/application.css +0 -13
- data/guides/code/getting_started/app/assets/stylesheets/comments.css.scss +0 -3
- data/guides/code/getting_started/app/assets/stylesheets/posts.css.scss +0 -3
- data/guides/code/getting_started/app/assets/stylesheets/welcome.css.scss +0 -3
- data/guides/code/getting_started/app/controllers/application_controller.rb +0 -5
- data/guides/code/getting_started/app/controllers/comments_controller.rb +0 -17
- data/guides/code/getting_started/app/controllers/posts_controller.rb +0 -47
- data/guides/code/getting_started/app/controllers/welcome_controller.rb +0 -4
- data/guides/code/getting_started/app/helpers/application_helper.rb +0 -2
- data/guides/code/getting_started/app/helpers/comments_helper.rb +0 -2
- data/guides/code/getting_started/app/helpers/posts_helper.rb +0 -2
- data/guides/code/getting_started/app/helpers/welcome_helper.rb +0 -2
- data/guides/code/getting_started/app/models/comment.rb +0 -3
- data/guides/code/getting_started/app/models/post.rb +0 -7
- data/guides/code/getting_started/app/views/comments/_comment.html.erb +0 -15
- data/guides/code/getting_started/app/views/comments/_form.html.erb +0 -13
- data/guides/code/getting_started/app/views/layouts/application.html.erb +0 -14
- data/guides/code/getting_started/app/views/posts/_form.html.erb +0 -27
- data/guides/code/getting_started/app/views/posts/edit.html.erb +0 -5
- data/guides/code/getting_started/app/views/posts/index.html.erb +0 -21
- data/guides/code/getting_started/app/views/posts/new.html.erb +0 -5
- data/guides/code/getting_started/app/views/posts/show.html.erb +0 -18
- data/guides/code/getting_started/app/views/welcome/index.html.erb +0 -3
- data/guides/code/getting_started/bin/bundle +0 -4
- data/guides/code/getting_started/bin/rails +0 -4
- data/guides/code/getting_started/bin/rake +0 -4
- data/guides/code/getting_started/config.ru +0 -4
- data/guides/code/getting_started/config/application.rb +0 -18
- data/guides/code/getting_started/config/boot.rb +0 -4
- data/guides/code/getting_started/config/database.yml +0 -25
- data/guides/code/getting_started/config/environment.rb +0 -5
- data/guides/code/getting_started/config/environments/development.rb +0 -30
- data/guides/code/getting_started/config/environments/production.rb +0 -80
- data/guides/code/getting_started/config/environments/test.rb +0 -36
- data/guides/code/getting_started/config/initializers/backtrace_silencers.rb +0 -7
- data/guides/code/getting_started/config/initializers/filter_parameter_logging.rb +0 -4
- data/guides/code/getting_started/config/initializers/inflections.rb +0 -16
- data/guides/code/getting_started/config/initializers/locale.rb +0 -9
- data/guides/code/getting_started/config/initializers/mime_types.rb +0 -5
- data/guides/code/getting_started/config/initializers/secret_token.rb +0 -12
- data/guides/code/getting_started/config/initializers/session_store.rb +0 -3
- data/guides/code/getting_started/config/initializers/wrap_parameters.rb +0 -14
- data/guides/code/getting_started/config/locales/en.yml +0 -23
- data/guides/code/getting_started/config/routes.rb +0 -7
- data/guides/code/getting_started/db/migrate/20130122042648_create_posts.rb +0 -10
- data/guides/code/getting_started/db/migrate/20130122045842_create_comments.rb +0 -11
- data/guides/code/getting_started/db/schema.rb +0 -33
- data/guides/code/getting_started/db/seeds.rb +0 -7
- data/guides/code/getting_started/public/404.html +0 -58
- data/guides/code/getting_started/public/422.html +0 -58
- data/guides/code/getting_started/public/500.html +0 -57
- data/guides/code/getting_started/public/favicon.ico +0 -0
- data/guides/code/getting_started/public/robots.txt +0 -5
- data/guides/code/getting_started/test/controllers/comments_controller_test.rb +0 -7
- data/guides/code/getting_started/test/controllers/posts_controller_test.rb +0 -7
- data/guides/code/getting_started/test/controllers/welcome_controller_test.rb +0 -9
- data/guides/code/getting_started/test/fixtures/comments.yml +0 -11
- data/guides/code/getting_started/test/fixtures/posts.yml +0 -9
- data/guides/code/getting_started/test/helpers/comments_helper_test.rb +0 -4
- data/guides/code/getting_started/test/helpers/posts_helper_test.rb +0 -4
- data/guides/code/getting_started/test/helpers/welcome_helper_test.rb +0 -4
- data/guides/code/getting_started/test/models/comment_test.rb +0 -7
- data/guides/code/getting_started/test/models/post_test.rb +0 -7
- data/guides/code/getting_started/test/test_helper.rb +0 -15
- data/guides/source/kindle/KINDLE.md +0 -26
@@ -129,6 +129,7 @@ body {
|
|
129
129
|
font-family: Helvetica, Arial, Sans-Serif;
|
130
130
|
text-decoration: none;
|
131
131
|
vertical-align: middle;
|
132
|
+
cursor: pointer;
|
132
133
|
}
|
133
134
|
.red-button:active {
|
134
135
|
border-top: none;
|
@@ -244,7 +245,7 @@ body {
|
|
244
245
|
#subCol {
|
245
246
|
position: absolute;
|
246
247
|
z-index: 0;
|
247
|
-
top:
|
248
|
+
top: 21px;
|
248
249
|
right: 0;
|
249
250
|
background: #FFF;
|
250
251
|
padding: 1em 1.5em 1em 1.25em;
|
@@ -380,9 +381,12 @@ a, a:link, a:visited {
|
|
380
381
|
font: inherit;
|
381
382
|
padding-left: .75em;
|
382
383
|
font-size: .95em;
|
383
|
-
background-position: 96%
|
384
|
+
background-position: 96% 16px;
|
384
385
|
-webkit-appearance: none;
|
385
386
|
}
|
387
|
+
.guides-index-small .guides-index-item:hover{
|
388
|
+
background-position: 96% -65px;
|
389
|
+
}
|
386
390
|
}
|
387
391
|
|
388
392
|
#guides {
|
@@ -36,7 +36,7 @@ hr {
|
|
36
36
|
}
|
37
37
|
|
38
38
|
h1,h2,h3,h4,h5,h6 { font-family: "Helvetica Neue", Arial, "Lucida Grande", sans-serif; }
|
39
|
-
code { font:.9em "Courier New", Monaco, Courier, monospace; }
|
39
|
+
code { font:.9em "Courier New", Monaco, Courier, monospace; display:inline}
|
40
40
|
|
41
41
|
img { float:left; margin:1.5em 1.5em 1.5em 0; }
|
42
42
|
a img { border:none; }
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# Activate the gem you are reporting the issue against.
|
2
|
+
gem 'rails', '4.2.0'
|
3
|
+
|
4
|
+
require 'rails'
|
5
|
+
require 'action_controller/railtie'
|
6
|
+
|
7
|
+
class TestApp < Rails::Application
|
8
|
+
config.root = File.dirname(__FILE__)
|
9
|
+
config.session_store :cookie_store, key: 'cookie_store_key'
|
10
|
+
secrets.secret_token = 'secret_token'
|
11
|
+
secrets.secret_key_base = 'secret_key_base'
|
12
|
+
|
13
|
+
config.logger = Logger.new($stdout)
|
14
|
+
Rails.logger = config.logger
|
15
|
+
|
16
|
+
routes.draw do
|
17
|
+
get '/' => 'test#index'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class TestController < ActionController::Base
|
22
|
+
include Rails.application.routes.url_helpers
|
23
|
+
|
24
|
+
def index
|
25
|
+
render text: 'Home'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
require 'minitest/autorun'
|
30
|
+
require 'rack/test'
|
31
|
+
|
32
|
+
# Ensure backward compatibility with Minitest 4
|
33
|
+
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
|
34
|
+
|
35
|
+
class BugTest < Minitest::Test
|
36
|
+
include Rack::Test::Methods
|
37
|
+
|
38
|
+
def test_returns_success
|
39
|
+
get '/'
|
40
|
+
assert last_response.ok?
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
def app
|
45
|
+
Rails.application
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
unless File.exist?('Gemfile')
|
2
|
+
File.write('Gemfile', <<-GEMFILE)
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
gem 'rails', github: 'rails/rails'
|
5
|
+
gem 'arel', github: 'rails/arel'
|
6
|
+
GEMFILE
|
7
|
+
|
8
|
+
system 'bundle'
|
9
|
+
end
|
10
|
+
|
11
|
+
require 'bundler'
|
12
|
+
Bundler.setup(:default)
|
13
|
+
|
14
|
+
require 'rails'
|
15
|
+
require 'action_controller/railtie'
|
16
|
+
|
17
|
+
class TestApp < Rails::Application
|
18
|
+
config.root = File.dirname(__FILE__)
|
19
|
+
config.session_store :cookie_store, key: 'cookie_store_key'
|
20
|
+
secrets.secret_token = 'secret_token'
|
21
|
+
secrets.secret_key_base = 'secret_key_base'
|
22
|
+
|
23
|
+
config.logger = Logger.new($stdout)
|
24
|
+
Rails.logger = config.logger
|
25
|
+
|
26
|
+
routes.draw do
|
27
|
+
get '/' => 'test#index'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class TestController < ActionController::Base
|
32
|
+
include Rails.application.routes.url_helpers
|
33
|
+
|
34
|
+
def index
|
35
|
+
render text: 'Home'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
require 'minitest/autorun'
|
40
|
+
require 'rack/test'
|
41
|
+
|
42
|
+
class BugTest < Minitest::Test
|
43
|
+
include Rack::Test::Methods
|
44
|
+
|
45
|
+
def test_returns_success
|
46
|
+
get '/'
|
47
|
+
assert last_response.ok?
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
def app
|
52
|
+
Rails.application
|
53
|
+
end
|
54
|
+
end
|
@@ -1,9 +1,12 @@
|
|
1
1
|
# Activate the gem you are reporting the issue against.
|
2
|
-
gem 'activerecord', '
|
2
|
+
gem 'activerecord', '4.2.0'
|
3
3
|
require 'active_record'
|
4
4
|
require 'minitest/autorun'
|
5
5
|
require 'logger'
|
6
6
|
|
7
|
+
# Ensure backward compatibility with Minitest 4
|
8
|
+
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
|
9
|
+
|
7
10
|
# This connection will do for database-independent bug reports.
|
8
11
|
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
|
9
12
|
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
@@ -25,7 +28,7 @@ class Comment < ActiveRecord::Base
|
|
25
28
|
belongs_to :post
|
26
29
|
end
|
27
30
|
|
28
|
-
class BugTest <
|
31
|
+
class BugTest < Minitest::Test
|
29
32
|
def test_association_stuff
|
30
33
|
post = Post.create!
|
31
34
|
post.comments << Comment.create!
|
@@ -1,7 +1,8 @@
|
|
1
|
-
unless File.
|
1
|
+
unless File.exist?('Gemfile')
|
2
2
|
File.write('Gemfile', <<-GEMFILE)
|
3
3
|
source 'https://rubygems.org'
|
4
4
|
gem 'rails', github: 'rails/rails'
|
5
|
+
gem 'arel', github: 'rails/arel'
|
5
6
|
gem 'sqlite3'
|
6
7
|
GEMFILE
|
7
8
|
|
@@ -36,7 +37,7 @@ class Comment < ActiveRecord::Base
|
|
36
37
|
belongs_to :post
|
37
38
|
end
|
38
39
|
|
39
|
-
class BugTest <
|
40
|
+
class BugTest < Minitest::Test
|
40
41
|
def test_association_stuff
|
41
42
|
post = Post.create!
|
42
43
|
post.comments << Comment.create!
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Activate the gems you are reporting the issue against.
|
2
|
+
gem 'activesupport', '4.2.0'
|
3
|
+
require 'active_support'
|
4
|
+
require 'active_support/core_ext/object/blank'
|
5
|
+
require 'minitest/autorun'
|
6
|
+
|
7
|
+
# Ensure backward compatibility with Minitest 4
|
8
|
+
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
|
9
|
+
|
10
|
+
class BugTest < Minitest::Test
|
11
|
+
def test_stuff
|
12
|
+
assert "zomg".present?
|
13
|
+
refute "".present?
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
unless File.exist?('Gemfile')
|
2
|
+
File.write('Gemfile', <<-GEMFILE)
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
gem 'rails', github: 'rails/rails'
|
5
|
+
gem 'arel', github: 'rails/arel'
|
6
|
+
GEMFILE
|
7
|
+
|
8
|
+
system 'bundle'
|
9
|
+
end
|
10
|
+
|
11
|
+
require 'bundler'
|
12
|
+
Bundler.setup(:default)
|
13
|
+
|
14
|
+
require 'active_support'
|
15
|
+
require 'active_support/core_ext/object/blank'
|
16
|
+
require 'minitest/autorun'
|
17
|
+
|
18
|
+
# Ensure backward compatibility with Minitest 4
|
19
|
+
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
|
20
|
+
|
21
|
+
class BugTest < Minitest::Test
|
22
|
+
def test_stuff
|
23
|
+
assert "zomg".present?
|
24
|
+
refute "".present?
|
25
|
+
end
|
26
|
+
end
|
data/guides/rails_guides.rb
CHANGED
@@ -5,7 +5,7 @@ $:.unshift pwd
|
|
5
5
|
def bundler?
|
6
6
|
# Note that rake sets the cwd to the one that contains the Rakefile
|
7
7
|
# being executed.
|
8
|
-
File.
|
8
|
+
File.exist?('Gemfile')
|
9
9
|
end
|
10
10
|
|
11
11
|
begin
|
@@ -22,13 +22,32 @@ end
|
|
22
22
|
|
23
23
|
begin
|
24
24
|
require 'redcarpet'
|
25
|
-
rescue
|
25
|
+
rescue LoadError
|
26
|
+
# This can happen if doc:guides is executed in an application.
|
27
|
+
$stderr.puts('Generating guides requires Redcarpet 3.1.2+.')
|
28
|
+
$stderr.puts(<<ERROR) if bundler?
|
29
|
+
Please add
|
30
|
+
|
31
|
+
gem 'redcarpet', '~> 3.1.2'
|
32
|
+
|
33
|
+
to the Gemfile, run
|
34
|
+
|
35
|
+
bundle install
|
36
|
+
|
37
|
+
and try again.
|
38
|
+
ERROR
|
39
|
+
exit 1
|
40
|
+
end
|
41
|
+
|
42
|
+
begin
|
43
|
+
require 'nokogiri'
|
44
|
+
rescue LoadError
|
26
45
|
# This can happen if doc:guides is executed in an application.
|
27
|
-
$stderr.puts('Generating guides requires
|
46
|
+
$stderr.puts('Generating guides requires Nokogiri.')
|
28
47
|
$stderr.puts(<<ERROR) if bundler?
|
29
48
|
Please add
|
30
49
|
|
31
|
-
gem '
|
50
|
+
gem 'nokogiri'
|
32
51
|
|
33
52
|
to the Gemfile, run
|
34
53
|
|
@@ -184,7 +184,7 @@ module RailsGuides
|
|
184
184
|
def generate?(source_file, output_file)
|
185
185
|
fin = File.join(source_dir, source_file)
|
186
186
|
fout = output_path_for(output_file)
|
187
|
-
all || !File.
|
187
|
+
all || !File.exist?(fout) || File.mtime(fout) < File.mtime(fin)
|
188
188
|
end
|
189
189
|
|
190
190
|
def generate_guide(guide, output_file)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
1
3
|
module RailsGuides
|
2
4
|
module Helpers
|
3
5
|
def guide(name, url, options = {}, &block)
|
@@ -17,7 +19,7 @@ module RailsGuides
|
|
17
19
|
end
|
18
20
|
|
19
21
|
def documents_flat
|
20
|
-
documents_by_section.
|
22
|
+
documents_by_section.flat_map {|section| section['documents']}
|
21
23
|
end
|
22
24
|
|
23
25
|
def finished_documents(documents)
|
@@ -37,7 +39,7 @@ module RailsGuides
|
|
37
39
|
def author(name, nick, image = 'credits_pic_blank.gif', &block)
|
38
40
|
image = "images/#{image}"
|
39
41
|
|
40
|
-
result =
|
42
|
+
result = tag(:img, :src => image, :class => 'left pic', :alt => name, :width => 91, :height => 91)
|
41
43
|
result << content_tag(:h3, name)
|
42
44
|
result << content_tag(:p, capture(&block))
|
43
45
|
content_tag(:div, result, :class => 'clearfix', :id => nick)
|
@@ -1,31 +1,37 @@
|
|
1
1
|
module RailsGuides
|
2
2
|
module Levenshtein
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
n =
|
3
|
+
# This code is based directly on the Text gem implementation
|
4
|
+
# Returns a value representing the "cost" of transforming str1 into str2
|
5
|
+
def self.distance str1, str2
|
6
|
+
s = str1
|
7
|
+
t = str2
|
8
|
+
n = s.length
|
9
|
+
m = t.length
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
0.upto(m) { |i| d << [i] }
|
13
|
-
0.upto(n) { |j| d[0][j] = j }
|
11
|
+
return m if (0 == n)
|
12
|
+
return n if (0 == m)
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
14
|
+
d = (0..m).to_a
|
15
|
+
x = nil
|
16
|
+
|
17
|
+
str1.each_char.each_with_index do |char1,i|
|
18
|
+
e = i+1
|
19
|
+
|
20
|
+
str2.each_char.each_with_index do |char2,j|
|
21
|
+
cost = (char1 == char2) ? 0 : 1
|
22
|
+
x = [
|
23
|
+
d[j+1] + 1, # insertion
|
24
|
+
e + 1, # deletion
|
25
|
+
d[j] + cost # substitution
|
26
|
+
].min
|
27
|
+
d[j] = e
|
28
|
+
e = x
|
24
29
|
end
|
30
|
+
|
31
|
+
d[m] = x
|
25
32
|
end
|
26
33
|
|
27
|
-
|
28
|
-
return d[m][n]
|
34
|
+
return x
|
29
35
|
end
|
30
36
|
end
|
31
37
|
end
|
@@ -47,8 +47,12 @@ module RailsGuides
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def dom_id_text(text)
|
50
|
-
|
51
|
-
|
50
|
+
escaped_chars = Regexp.escape('\\/`*_{}[]()#+-.!:,;|&<>^~=\'"')
|
51
|
+
|
52
|
+
text.downcase.gsub(/\?/, '-questionmark')
|
53
|
+
.gsub(/!/, '-bang')
|
54
|
+
.gsub(/[#{escaped_chars}]+/, ' ').strip
|
55
|
+
.gsub(/\s+/, '-')
|
52
56
|
end
|
53
57
|
|
54
58
|
def engine
|
@@ -79,10 +83,10 @@ module RailsGuides
|
|
79
83
|
def generate_structure
|
80
84
|
@headings_for_index = []
|
81
85
|
if @body.present?
|
82
|
-
@body = Nokogiri::HTML(@body).tap do |doc|
|
86
|
+
@body = Nokogiri::HTML.fragment(@body).tap do |doc|
|
83
87
|
hierarchy = []
|
84
88
|
|
85
|
-
doc.
|
89
|
+
doc.children.each do |node|
|
86
90
|
if node.name =~ /^h[3-6]$/
|
87
91
|
case node.name
|
88
92
|
when 'h3'
|
@@ -116,7 +120,7 @@ module RailsGuides
|
|
116
120
|
end
|
117
121
|
end
|
118
122
|
|
119
|
-
@index = Nokogiri::HTML(engine.render(raw_index)).tap do |doc|
|
123
|
+
@index = Nokogiri::HTML.fragment(engine.render(raw_index)).tap do |doc|
|
120
124
|
doc.at('ol')[:class] = 'chapters'
|
121
125
|
end.to_html
|
122
126
|
|
@@ -130,8 +134,8 @@ module RailsGuides
|
|
130
134
|
end
|
131
135
|
|
132
136
|
def generate_title
|
133
|
-
if heading = Nokogiri::HTML(@header).at(:h2)
|
134
|
-
@title = "#{heading.text} — Ruby on Rails Guides"
|
137
|
+
if heading = Nokogiri::HTML.fragment(@header).at(:h2)
|
138
|
+
@title = "#{heading.text} — Ruby on Rails Guides"
|
135
139
|
else
|
136
140
|
@title = "Ruby on Rails Guides"
|
137
141
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Ruby on Rails 2.2 Release Notes
|
2
2
|
===============================
|
3
3
|
|
4
|
-
Rails 2.2 delivers a number of new and improved features. This list covers the major upgrades, but doesn't include every little bug fix and change. If you want to see everything, check out the [list of commits](http://github.com/rails/rails/commits/
|
4
|
+
Rails 2.2 delivers a number of new and improved features. This list covers the major upgrades, but doesn't include every little bug fix and change. If you want to see everything, check out the [list of commits](http://github.com/rails/rails/commits/2-2-stable) in the main Rails repository on GitHub.
|
5
5
|
|
6
6
|
Along with Rails, 2.2 marks the launch of the [Ruby on Rails Guides](http://guides.rubyonrails.org/), the first results of the ongoing [Rails Guides hackfest](http://hackfest.rubyonrails.org/guide). This site will deliver high-quality documentation of the major features of Rails.
|
7
7
|
|
@@ -327,7 +327,7 @@ Other features of memoization include `unmemoize`, `unmemoize_all`, and `memoize
|
|
327
327
|
The `each_with_object` method provides an alternative to `inject`, using a method backported from Ruby 1.9. It iterates over a collection, passing the current element and the memo into the block.
|
328
328
|
|
329
329
|
```ruby
|
330
|
-
%w(foo bar).each_with_object({}) { |str, hsh| hsh[str] = str.upcase }
|
330
|
+
%w(foo bar).each_with_object({}) { |str, hsh| hsh[str] = str.upcase } # => {'foo' => 'FOO', 'bar' => 'BAR'}
|
331
331
|
```
|
332
332
|
|
333
333
|
Lead Contributor: [Adam Keys](http://therealadam.com/)
|
@@ -366,7 +366,7 @@ Lead Contributor: [Daniel Schierbeck](http://workingwithrails.com/person/5830-da
|
|
366
366
|
* `Inflector#parameterize` produces a URL-ready version of its input, for use in `to_param`.
|
367
367
|
* `Time#advance` recognizes fractional days and weeks, so you can do `1.7.weeks.ago`, `1.5.hours.since`, and so on.
|
368
368
|
* The included TzInfo library has been upgraded to version 0.3.12.
|
369
|
-
* `
|
369
|
+
* `ActiveSupport::StringInquirer` gives you a pretty way to test for equality in strings: `ActiveSupport::StringInquirer.new("abc").abc? => true`
|
370
370
|
|
371
371
|
Railties
|
372
372
|
--------
|