rails 4.0.0.beta1 → 4.0.0.rc1

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 (55) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +78 -0
  3. data/guides/CHANGELOG.md +3 -0
  4. data/guides/assets/images/getting_started/unknown_action_create_for_posts.png +0 -0
  5. data/guides/bug_report_templates/active_record_gem.rb +37 -0
  6. data/guides/bug_report_templates/active_record_master.rb +48 -0
  7. data/guides/code/getting_started/Gemfile +16 -11
  8. data/guides/code/getting_started/app/controllers/comments_controller.rb +2 -2
  9. data/guides/code/getting_started/app/controllers/posts_controller.rb +2 -2
  10. data/guides/code/getting_started/config/application.rb +3 -2
  11. data/guides/code/getting_started/config/initializers/session_store.rb +1 -1
  12. data/guides/code/getting_started/config/routes.rb +2 -2
  13. data/guides/code/getting_started/public/404.html +41 -10
  14. data/guides/code/getting_started/public/422.html +42 -10
  15. data/guides/code/getting_started/public/500.html +41 -10
  16. data/guides/rails_guides/markdown/renderer.rb +1 -1
  17. data/guides/source/2_2_release_notes.md +15 -15
  18. data/guides/source/4_0_release_notes.md +1 -7
  19. data/guides/source/action_controller_overview.md +176 -22
  20. data/guides/source/action_mailer_basics.md +246 -141
  21. data/guides/source/action_view_overview.md +3 -8
  22. data/guides/source/active_record_basics.md +98 -95
  23. data/guides/source/active_record_querying.md +90 -17
  24. data/guides/source/active_record_validations.md +41 -0
  25. data/guides/source/active_support_core_extensions.md +23 -3
  26. data/guides/source/active_support_instrumentation.md +6 -6
  27. data/guides/source/asset_pipeline.md +1 -1
  28. data/guides/source/association_basics.md +34 -10
  29. data/guides/source/caching_with_rails.md +2 -7
  30. data/guides/source/command_line.md +7 -7
  31. data/guides/source/configuring.md +3 -3
  32. data/guides/source/contributing_to_ruby_on_rails.md +38 -5
  33. data/guides/source/credits.html.erb +1 -1
  34. data/guides/source/debugging_rails_applications.md +19 -22
  35. data/guides/source/development_dependencies_install.md +2 -2
  36. data/guides/source/documents.yaml +5 -1
  37. data/guides/source/engines.md +21 -16
  38. data/guides/source/form_helpers.md +28 -7
  39. data/guides/source/generators.md +2 -2
  40. data/guides/source/getting_started.md +14 -13
  41. data/guides/source/i18n.md +22 -0
  42. data/guides/source/initialization.md +1 -1
  43. data/guides/source/layouts_and_rendering.md +60 -4
  44. data/guides/source/migrations.md +27 -2
  45. data/guides/source/rails_application_templates.md +11 -11
  46. data/guides/source/rails_on_rack.md +9 -6
  47. data/guides/source/routing.md +19 -3
  48. data/guides/source/ruby_on_rails_guides_guidelines.md +1 -1
  49. data/guides/source/security.md +2 -2
  50. data/guides/source/testing.md +106 -85
  51. data/guides/source/upgrading_ruby_on_rails.md +112 -9
  52. data/guides/source/working_with_javascript_in_rails.md +1 -0
  53. metadata +17 -16
  54. data/README.rdoc +0 -77
  55. data/guides/code/getting_started/app/assets/images/rails.png +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f57fa29cabbd61ae7b119970e07c748447b5e2ae
4
- data.tar.gz: 1192cb45ddb9eccb8ca3c28b46799c87636a4a5b
3
+ metadata.gz: 250f660778b901161649e1697a96c2829472bdb4
4
+ data.tar.gz: 1ecf691da54de69d04232a42a5ed814d6da7146e
5
5
  SHA512:
6
- metadata.gz: 204c44dd99177cadd3d52d797f831cb6a437c99678b0348efb2858d37a5fccc4948fcf52c87d71e2aed4f67ffc6408fa507e06355ef0415d41cefe55f2ec8d44
7
- data.tar.gz: 5ea99d648ad7cc31a015ce3288cd5e730bb28489ba0ce795866b44a97d99ff1d28d34e6a9d5623f6a01ce08797d2a8bc65eb755136adddd30642c30dd316a66f
6
+ metadata.gz: 2b47aa456647886a9efb163161ea0f3ed3faba3581c31d01d324dfd0883cc3b7a6705252ea0857a6040d76e2394acffd34533a997fd03eef4c87192d9b9e399e
7
+ data.tar.gz: 23b7a83cb7bce1949b177fb2891f25057bb10fde695aaa1b3d2488435b498c206c4876f93de9f009097c11c41de82a4b988c1efd8555a773d20d3754dfc9a96a
@@ -0,0 +1,78 @@
1
+ ## Welcome to Rails
2
+
3
+ Rails is a web-application framework that includes everything needed to
4
+ create database-backed web applications according to the
5
+ [Model-View-Controller (MVC)](http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller)
6
+ pattern.
7
+
8
+ Understanding the MVC pattern is key to understanding Rails. MVC divides your
9
+ application into three layers, each with a specific responsibility.
10
+
11
+ The _View layer_ is composed of "templates" that are responsible for providing
12
+ appropriate representations of your application's resources. Templates can
13
+ come in a variety of formats, but most view templates are HTML with embedded
14
+ Ruby code (ERB files).
15
+
16
+ The _Model layer_ represents your domain model (such as Account, Product,
17
+ Person, Post, etc.) and encapsulates the business logic that is specific to
18
+ your application. In Rails, database-backed model classes are derived from
19
+ `ActiveRecord::Base`. Active Record allows you to present the data from
20
+ database rows as objects and embellish these data objects with business logic
21
+ methods. Although most Rails models are backed by a database, models can also
22
+ be ordinary Ruby classes, or Ruby classes that implement a set of interfaces
23
+ as provided by the Active Model module. You can read more about Active Record
24
+ in its [README](activerecord/README.rdoc).
25
+
26
+ The _Controller layer_ is responsible for handling incoming HTTP requests and
27
+ providing a suitable response. Usually this means returning HTML, but Rails
28
+ controllers can also generate XML, JSON, PDFs, mobile-specific views, and
29
+ more. Controllers manipulate models and render view templates in order to
30
+ generate the appropriate HTTP response.
31
+
32
+ In Rails, the Controller and View layers are handled together by Action Pack.
33
+ These two layers are bundled in a single package due to their heavy interdependence.
34
+ This is unlike the relationship between Active Record and Action Pack, which are
35
+ independent. Each of these packages can be used independently outside of Rails. You
36
+ can read more about Action Pack in its [README](actionpack/README.rdoc).
37
+
38
+ ## Getting Started
39
+
40
+ 1. Install Rails at the command prompt if you haven't yet:
41
+
42
+ gem install rails
43
+
44
+ 2. At the command prompt, create a new Rails application:
45
+
46
+ rails new myapp
47
+
48
+ where "myapp" is the application name.
49
+
50
+ 3. Change directory to `myapp` and start the web server:
51
+
52
+ cd myapp
53
+ rails server
54
+
55
+ Run with `--help` or `-h` for options.
56
+
57
+ 4. Go to http://localhost:3000 and you'll see: "Welcome aboard: You're riding Ruby on Rails!"
58
+
59
+ 5. Follow the guidelines to start developing your application. You may find
60
+ the following resources handy:
61
+ * [Getting Started with Rails](http://guides.rubyonrails.org/getting_started.html)
62
+ * [Ruby on Rails Guides](http://guides.rubyonrails.org)
63
+ * [The API Documentation](http://api.rubyonrails.org)
64
+ * [Ruby on Rails Tutorial](http://ruby.railstutorial.org/ruby-on-rails-tutorial-book)
65
+
66
+ ## Contributing
67
+
68
+ We encourage you to contribute to Ruby on Rails! Please check out the
69
+ [Contributing to Ruby on Rails guide](http://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html) for guidelines about how to proceed. [Join us!](http://contributors.rubyonrails.org)
70
+
71
+ ## Code Status
72
+
73
+ * [![Build Status](https://api.travis-ci.org/rails/rails.png)](https://travis-ci.org/rails/rails)
74
+ * [![Dependencies](https://gemnasium.com/rails/rails.png?travis)](https://gemnasium.com/rails/rails)
75
+
76
+ ## License
77
+
78
+ Ruby on Rails is released under the [MIT License](http://www.opensource.org/licenses/MIT).
@@ -1,3 +1,6 @@
1
+ ## Rails 4.0.0 (unreleased) ##
2
+ * Change Service pages(404, etc). *Stanislav Sobolev*
3
+
1
4
  ## Rails 4.0.0.beta1 (unreleased) ##
2
5
 
3
6
  * Split Validations and Callbacks guide into two. *Steve Klabnik*
@@ -0,0 +1,37 @@
1
+ # Activate the gem you are reporting the issue against.
2
+ gem 'activerecord', '3.2.11'
3
+ require 'active_record'
4
+ require 'minitest/autorun'
5
+ require 'logger'
6
+
7
+ # This connection will do for database-independent bug reports.
8
+ ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
9
+ ActiveRecord::Base.logger = Logger.new(STDOUT)
10
+
11
+ ActiveRecord::Schema.define do
12
+ create_table :posts do |t|
13
+ end
14
+
15
+ create_table :comments do |t|
16
+ t.integer :post_id
17
+ end
18
+ end
19
+
20
+ class Post < ActiveRecord::Base
21
+ has_many :comments
22
+ end
23
+
24
+ class Comment < ActiveRecord::Base
25
+ belongs_to :post
26
+ end
27
+
28
+ class BugTest < MiniTest::Unit::TestCase
29
+ def test_association_stuff
30
+ post = Post.create!
31
+ post.comments << Comment.create!
32
+
33
+ assert_equal 1, post.comments.count
34
+ assert_equal 1, Comment.count
35
+ assert_equal post.id, Comment.first.post.id
36
+ end
37
+ end
@@ -0,0 +1,48 @@
1
+ unless File.exists?('Gemfile')
2
+ File.write('Gemfile', <<-GEMFILE)
3
+ source 'https://rubygems.org'
4
+ gem 'rails', github: 'rails/rails'
5
+ gem 'sqlite3'
6
+ GEMFILE
7
+
8
+ system 'bundle'
9
+ end
10
+
11
+ require 'bundler'
12
+ Bundler.setup(:default)
13
+
14
+ require 'active_record'
15
+ require 'minitest/autorun'
16
+ require 'logger'
17
+
18
+ # This connection will do for database-independent bug reports.
19
+ ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
20
+ ActiveRecord::Base.logger = Logger.new(STDOUT)
21
+
22
+ ActiveRecord::Schema.define do
23
+ create_table :posts do |t|
24
+ end
25
+
26
+ create_table :comments do |t|
27
+ t.integer :post_id
28
+ end
29
+ end
30
+
31
+ class Post < ActiveRecord::Base
32
+ has_many :comments
33
+ end
34
+
35
+ class Comment < ActiveRecord::Base
36
+ belongs_to :post
37
+ end
38
+
39
+ class BugTest < MiniTest::Unit::TestCase
40
+ def test_association_stuff
41
+ post = Post.create!
42
+ post.comments << Comment.create!
43
+
44
+ assert_equal 1, post.comments.count
45
+ assert_equal 1, Comment.count
46
+ assert_equal post.id, Comment.first.post.id
47
+ end
48
+ end
@@ -2,28 +2,33 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rails', '4.0.0'
4
4
 
5
+ # Use sqlite3 as the database for Active Record
5
6
  gem 'sqlite3'
6
7
 
7
- # Gems used only for assets and not required
8
- # in production environments by default.
9
- group :assets do
10
- gem 'sprockets-rails'
11
- gem 'sass-rails'
12
- gem 'coffee-rails'
8
+ # Use SCSS for stylesheets
9
+ gem 'sass-rails'
13
10
 
14
- # See https://github.com/sstephenson/execjs#readme for more supported runtimes
15
- # gem 'therubyracer', platforms: :ruby
11
+ # Use CoffeeScript for .js.coffee assets and views
12
+ gem 'coffee-rails'
16
13
 
17
- gem 'uglifier', '>= 1.0.3'
18
- end
14
+ # See https://github.com/sstephenson/execjs#readme for more supported runtimes
15
+ # gem 'therubyracer', platforms: :ruby
16
+
17
+ # Use Uglifier as compressor for JavaScript assets
18
+ gem 'uglifier', '>= 1.0.3'
19
19
 
20
20
  gem 'jquery-rails'
21
21
 
22
22
  # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
23
23
  gem 'turbolinks'
24
24
 
25
+ group :doc do
26
+ # bundle exec rake doc:rails generates the API under doc/api.
27
+ gem 'sdoc', require: false
28
+ end
29
+
25
30
  # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
26
- gem 'jbuilder', '~> 1.0.1'
31
+ gem 'jbuilder', '~> 1.2'
27
32
 
28
33
  # To use ActiveModel has_secure_password
29
34
  # gem 'bcrypt-ruby', '~> 3.0.0'
@@ -1,7 +1,7 @@
1
1
  class CommentsController < ApplicationController
2
2
 
3
-   http_basic_authenticate_with name: "dhh", password: "secret", only: :destroy
4
-
3
+ http_basic_authenticate_with name: "dhh", password: "secret", only: :destroy
4
+
5
5
  def create
6
6
  @post = Post.find(params[:post_id])
7
7
  @comment = @post.comments.create(params[:comment].permit(:commenter, :body))
@@ -1,7 +1,7 @@
1
1
  class PostsController < ApplicationController
2
2
 
3
-   http_basic_authenticate_with name: "dhh", password: "secret", except: [:index, :show]
4
-
3
+ http_basic_authenticate_with name: "dhh", password: "secret", except: [:index, :show]
4
+
5
5
  def index
6
6
  @posts = Post.all
7
7
  end
@@ -2,8 +2,9 @@ require File.expand_path('../boot', __FILE__)
2
2
 
3
3
  require 'rails/all'
4
4
 
5
- # Assets should be precompiled for production (so we don't need the gems loaded then)
6
- Bundler.require(*Rails.groups(assets: %w(development test)))
5
+ # Require the gems listed in Gemfile, including any gems
6
+ # you've limited to :test, :development, or :production.
7
+ Bundler.require(:default, Rails.env)
7
8
 
8
9
  module Blog
9
10
  class Application < Rails::Application
@@ -1,3 +1,3 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
- Blog::Application.config.session_store :encrypted_cookie_store, key: '_blog_session'
3
+ Blog::Application.config.session_store :cookie_store, key: '_blog_session'
@@ -2,6 +2,6 @@ Blog::Application.routes.draw do
2
2
  resources :posts do
3
3
  resources :comments
4
4
  end
5
-
6
- root to: "welcome#index"
5
+
6
+ root "welcome#index"
7
7
  end
@@ -3,16 +3,47 @@
3
3
  <head>
4
4
  <title>The page you were looking for doesn't exist (404)</title>
5
5
  <style>
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
16
47
  </style>
17
48
  </head>
18
49
 
@@ -3,16 +3,47 @@
3
3
  <head>
4
4
  <title>The change you wanted was rejected (422)</title>
5
5
  <style>
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
16
47
  </style>
17
48
  </head>
18
49
 
@@ -22,5 +53,6 @@
22
53
  <h1>The change you wanted was rejected.</h1>
23
54
  <p>Maybe you tried to change something you didn't have access to.</p>
24
55
  </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
25
57
  </body>
26
58
  </html>
@@ -3,16 +3,47 @@
3
3
  <head>
4
4
  <title>We're sorry, but something went wrong (500)</title>
5
5
  <style>
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
16
47
  </style>
17
48
  </head>
18
49