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.
- checksums.yaml +4 -4
- data/README.md +78 -0
- data/guides/CHANGELOG.md +3 -0
- data/guides/assets/images/getting_started/unknown_action_create_for_posts.png +0 -0
- data/guides/bug_report_templates/active_record_gem.rb +37 -0
- data/guides/bug_report_templates/active_record_master.rb +48 -0
- data/guides/code/getting_started/Gemfile +16 -11
- data/guides/code/getting_started/app/controllers/comments_controller.rb +2 -2
- data/guides/code/getting_started/app/controllers/posts_controller.rb +2 -2
- data/guides/code/getting_started/config/application.rb +3 -2
- data/guides/code/getting_started/config/initializers/session_store.rb +1 -1
- data/guides/code/getting_started/config/routes.rb +2 -2
- data/guides/code/getting_started/public/404.html +41 -10
- data/guides/code/getting_started/public/422.html +42 -10
- data/guides/code/getting_started/public/500.html +41 -10
- data/guides/rails_guides/markdown/renderer.rb +1 -1
- data/guides/source/2_2_release_notes.md +15 -15
- data/guides/source/4_0_release_notes.md +1 -7
- data/guides/source/action_controller_overview.md +176 -22
- data/guides/source/action_mailer_basics.md +246 -141
- data/guides/source/action_view_overview.md +3 -8
- data/guides/source/active_record_basics.md +98 -95
- data/guides/source/active_record_querying.md +90 -17
- data/guides/source/active_record_validations.md +41 -0
- data/guides/source/active_support_core_extensions.md +23 -3
- data/guides/source/active_support_instrumentation.md +6 -6
- data/guides/source/asset_pipeline.md +1 -1
- data/guides/source/association_basics.md +34 -10
- data/guides/source/caching_with_rails.md +2 -7
- data/guides/source/command_line.md +7 -7
- data/guides/source/configuring.md +3 -3
- data/guides/source/contributing_to_ruby_on_rails.md +38 -5
- data/guides/source/credits.html.erb +1 -1
- data/guides/source/debugging_rails_applications.md +19 -22
- data/guides/source/development_dependencies_install.md +2 -2
- data/guides/source/documents.yaml +5 -1
- data/guides/source/engines.md +21 -16
- data/guides/source/form_helpers.md +28 -7
- data/guides/source/generators.md +2 -2
- data/guides/source/getting_started.md +14 -13
- data/guides/source/i18n.md +22 -0
- data/guides/source/initialization.md +1 -1
- data/guides/source/layouts_and_rendering.md +60 -4
- data/guides/source/migrations.md +27 -2
- data/guides/source/rails_application_templates.md +11 -11
- data/guides/source/rails_on_rack.md +9 -6
- data/guides/source/routing.md +19 -3
- data/guides/source/ruby_on_rails_guides_guidelines.md +1 -1
- data/guides/source/security.md +2 -2
- data/guides/source/testing.md +106 -85
- data/guides/source/upgrading_ruby_on_rails.md +112 -9
- data/guides/source/working_with_javascript_in_rails.md +1 -0
- metadata +17 -16
- data/README.rdoc +0 -77
- 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 250f660778b901161649e1697a96c2829472bdb4
|
4
|
+
data.tar.gz: 1ecf691da54de69d04232a42a5ed814d6da7146e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b47aa456647886a9efb163161ea0f3ed3faba3581c31d01d324dfd0883cc3b7a6705252ea0857a6040d76e2394acffd34533a997fd03eef4c87192d9b9e399e
|
7
|
+
data.tar.gz: 23b7a83cb7bce1949b177fb2891f25057bb10fde695aaa1b3d2488435b498c206c4876f93de9f009097c11c41de82a4b988c1efd8555a773d20d3754dfc9a96a
|
data/README.md
ADDED
@@ -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).
|
data/guides/CHANGELOG.md
CHANGED
Binary file
|
@@ -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
|
-
#
|
8
|
-
|
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
|
-
|
15
|
-
|
11
|
+
# Use CoffeeScript for .js.coffee assets and views
|
12
|
+
gem 'coffee-rails'
|
16
13
|
|
17
|
-
|
18
|
-
|
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.
|
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
|
-
|
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
|
-
|
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
|
-
#
|
6
|
-
|
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
|
@@ -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
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
|