rails 4.1.16 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -10
- data/guides/CHANGELOG.md +15 -100
- data/guides/Rakefile +5 -3
- data/guides/assets/javascripts/guides.js +6 -0
- data/guides/assets/stylesheets/main.css +4 -1
- data/guides/bug_report_templates/action_controller_master.rb +1 -0
- data/guides/rails_guides/helpers.rb +1 -1
- data/guides/rails_guides/levenshtein.rb +29 -21
- data/guides/rails_guides/markdown/renderer.rb +1 -1
- data/guides/rails_guides/markdown.rb +11 -7
- data/guides/rails_guides.rb +2 -2
- data/guides/source/2_2_release_notes.md +1 -1
- data/guides/source/2_3_release_notes.md +4 -4
- data/guides/source/3_0_release_notes.md +8 -8
- data/guides/source/3_1_release_notes.md +6 -3
- data/guides/source/3_2_release_notes.md +6 -3
- data/guides/source/4_0_release_notes.md +6 -3
- data/guides/source/4_1_release_notes.md +5 -6
- data/guides/source/4_2_release_notes.md +850 -0
- data/guides/source/_license.html.erb +1 -1
- data/guides/source/_welcome.html.erb +2 -8
- data/guides/source/action_controller_overview.md +81 -7
- data/guides/source/action_mailer_basics.md +91 -28
- data/guides/source/action_view_overview.md +148 -130
- data/guides/source/active_job_basics.md +318 -0
- data/guides/source/active_model_basics.md +371 -17
- data/guides/source/active_record_basics.md +19 -18
- data/guides/source/active_record_callbacks.md +12 -9
- data/guides/source/{migrations.md → active_record_migrations.md} +95 -220
- data/guides/source/active_record_postgresql.md +433 -0
- data/guides/source/active_record_querying.md +263 -265
- data/guides/source/active_record_validations.md +20 -11
- data/guides/source/active_support_core_extensions.md +159 -72
- data/guides/source/active_support_instrumentation.md +10 -7
- data/guides/source/api_documentation_guidelines.md +62 -16
- data/guides/source/asset_pipeline.md +258 -63
- data/guides/source/association_basics.md +81 -74
- data/guides/source/caching_with_rails.md +32 -7
- data/guides/source/command_line.md +52 -30
- data/guides/source/configuring.md +132 -29
- data/guides/source/constant_autoloading_and_reloading.md +1297 -0
- data/guides/source/contributing_to_ruby_on_rails.md +192 -112
- data/guides/source/credits.html.erb +2 -2
- data/guides/source/debugging_rails_applications.md +440 -286
- data/guides/source/development_dependencies_install.md +47 -36
- data/guides/source/documents.yaml +19 -7
- data/guides/source/engines.md +182 -182
- data/guides/source/form_helpers.md +79 -56
- data/guides/source/generators.md +24 -11
- data/guides/source/getting_started.md +337 -198
- data/guides/source/i18n.md +108 -65
- data/guides/source/index.html.erb +1 -0
- data/guides/source/initialization.md +108 -61
- data/guides/source/layout.html.erb +1 -4
- data/guides/source/layouts_and_rendering.md +27 -25
- data/guides/source/maintenance_policy.md +6 -3
- data/guides/source/nested_model_forms.md +7 -4
- data/guides/source/plugins.md +27 -27
- data/guides/source/rails_application_templates.md +21 -3
- data/guides/source/rails_on_rack.md +8 -4
- data/guides/source/routing.md +98 -72
- data/guides/source/ruby_on_rails_guides_guidelines.md +11 -12
- data/guides/source/security.md +38 -32
- data/guides/source/testing.md +188 -117
- data/guides/source/upgrading_ruby_on_rails.md +254 -28
- data/guides/source/working_with_javascript_in_rails.md +18 -16
- data/guides/w3c_validator.rb +2 -0
- metadata +40 -96
- data/guides/bug_report_templates/generic_gem.rb +0 -15
- data/guides/bug_report_templates/generic_master.rb +0 -26
- data/guides/code/getting_started/Gemfile +0 -40
- data/guides/code/getting_started/Gemfile.lock +0 -125
- 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 -15
- 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 -23
- data/guides/code/getting_started/app/controllers/posts_controller.rb +0 -53
- 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 -4
- 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/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/config.ru +0 -4
- 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 -60
- data/guides/code/getting_started/public/422.html +0 -60
- data/guides/code/getting_started/public/500.html +0 -59
- 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 -12
@@ -1,5 +1,4 @@
|
|
1
|
-
<!DOCTYPE html
|
2
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
1
|
+
<!DOCTYPE html>
|
3
2
|
|
4
3
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
4
|
<head>
|
@@ -36,7 +35,6 @@
|
|
36
35
|
<li class="more-info"><a href="https://github.com/rails/rails">Code</a></li>
|
37
36
|
<li class="more-info"><a href="http://rubyonrails.org/screencasts">Screencasts</a></li>
|
38
37
|
<li class="more-info"><a href="http://rubyonrails.org/documentation">Documentation</a></li>
|
39
|
-
<li class="more-info"><a href="http://rubyonrails.org/ecosystem">Ecosystem</a></li>
|
40
38
|
<li class="more-info"><a href="http://rubyonrails.org/community">Community</a></li>
|
41
39
|
<li class="more-info"><a href="http://weblog.rubyonrails.org/">Blog</a></li>
|
42
40
|
</ul>
|
@@ -78,7 +76,6 @@
|
|
78
76
|
</select>
|
79
77
|
</li>
|
80
78
|
</ul>
|
81
|
-
</div>
|
82
79
|
</div>
|
83
80
|
</div>
|
84
81
|
<hr class="hide" />
|
@@ -175,22 +175,23 @@ render template: "products/show"
|
|
175
175
|
|
176
176
|
#### Rendering an Arbitrary File
|
177
177
|
|
178
|
-
The `render` method can also use a view that's entirely outside of your application:
|
178
|
+
The `render` method can also use a view that's entirely outside of your application (perhaps you're sharing views between two Rails applications):
|
179
179
|
|
180
180
|
```ruby
|
181
|
-
render
|
181
|
+
render "/u/apps/warehouse_app/current/app/views/products/show"
|
182
182
|
```
|
183
183
|
|
184
|
-
|
185
|
-
|
184
|
+
Rails determines that this is a file render because of the leading slash character. To be explicit, you can use the `:file` option (which was required on Rails 2.2 and earlier):
|
185
|
+
|
186
|
+
```ruby
|
187
|
+
render file: "/u/apps/warehouse_app/current/app/views/products/show"
|
188
|
+
```
|
186
189
|
|
187
|
-
|
188
|
-
since an attacker could use this action to access security sensitive files in your file system.
|
190
|
+
The `:file` option takes an absolute file-system path. Of course, you need to have rights to the view that you're using to render the content.
|
189
191
|
|
190
|
-
NOTE: By default, the file is rendered
|
192
|
+
NOTE: By default, the file is rendered using the current layout.
|
191
193
|
|
192
|
-
TIP: If you're running Rails on Microsoft Windows, you should use the `:file` option to
|
193
|
-
render a file, because Windows filenames do not have the same format as Unix filenames.
|
194
|
+
TIP: If you're running Rails on Microsoft Windows, you should use the `:file` option to render a file, because Windows filenames do not have the same format as Unix filenames.
|
194
195
|
|
195
196
|
#### Wrapping it up
|
196
197
|
|
@@ -247,7 +248,8 @@ service requests that are expecting something other than proper HTML.
|
|
247
248
|
|
248
249
|
NOTE: By default, if you use the `:plain` option, the text is rendered without
|
249
250
|
using the current layout. If you want Rails to put the text into the current
|
250
|
-
layout, you need to add the `layout: true` option.
|
251
|
+
layout, you need to add the `layout: true` option and use the `.txt.erb`
|
252
|
+
extension for the layout file.
|
251
253
|
|
252
254
|
#### Rendering HTML
|
253
255
|
|
@@ -262,7 +264,7 @@ TIP: This is useful when you're rendering a small snippet of HTML code.
|
|
262
264
|
However, you might want to consider moving it to a template file if the markup
|
263
265
|
is complex.
|
264
266
|
|
265
|
-
NOTE: This option will escape HTML entities if the string is not
|
267
|
+
NOTE: This option will escape HTML entities if the string is not HTML safe.
|
266
268
|
|
267
269
|
#### Rendering JSON
|
268
270
|
|
@@ -307,7 +309,7 @@ TIP: This option should be used only if you don't care about the content type of
|
|
307
309
|
the response. Using `:plain` or `:html` might be more appropriate in most of the
|
308
310
|
time.
|
309
311
|
|
310
|
-
NOTE: Unless
|
312
|
+
NOTE: Unless overridden, your response returned from this render option will be
|
311
313
|
`text/html`, as that is the default content type of Action Dispatch response.
|
312
314
|
|
313
315
|
#### Options for `render`
|
@@ -505,33 +507,33 @@ Layout declarations cascade downward in the hierarchy, and more specific layout
|
|
505
507
|
end
|
506
508
|
```
|
507
509
|
|
508
|
-
* `
|
510
|
+
* `articles_controller.rb`
|
509
511
|
|
510
512
|
```ruby
|
511
|
-
class
|
513
|
+
class ArticlesController < ApplicationController
|
512
514
|
end
|
513
515
|
```
|
514
516
|
|
515
|
-
* `
|
517
|
+
* `special_articles_controller.rb`
|
516
518
|
|
517
519
|
```ruby
|
518
|
-
class
|
520
|
+
class SpecialArticlesController < ArticlesController
|
519
521
|
layout "special"
|
520
522
|
end
|
521
523
|
```
|
522
524
|
|
523
|
-
* `
|
525
|
+
* `old_articles_controller.rb`
|
524
526
|
|
525
527
|
```ruby
|
526
|
-
class
|
528
|
+
class OldArticlesController < SpecialArticlesController
|
527
529
|
layout false
|
528
530
|
|
529
531
|
def show
|
530
|
-
@
|
532
|
+
@article = Article.find(params[:id])
|
531
533
|
end
|
532
534
|
|
533
535
|
def index
|
534
|
-
@
|
536
|
+
@old_articles = Article.older
|
535
537
|
render layout: "old"
|
536
538
|
end
|
537
539
|
# ...
|
@@ -541,10 +543,10 @@ Layout declarations cascade downward in the hierarchy, and more specific layout
|
|
541
543
|
In this application:
|
542
544
|
|
543
545
|
* In general, views will be rendered in the `main` layout
|
544
|
-
* `
|
545
|
-
* `
|
546
|
-
* `
|
547
|
-
* `
|
546
|
+
* `ArticlesController#index` will use the `main` layout
|
547
|
+
* `SpecialArticlesController#index` will use the `special` layout
|
548
|
+
* `OldArticlesController#show` will use no layout at all
|
549
|
+
* `OldArticlesController#index` will use the `old` layout
|
548
550
|
|
549
551
|
#### Avoiding Double Render Errors
|
550
552
|
|
@@ -902,7 +904,7 @@ You can also specify multiple videos to play by passing an array of videos to th
|
|
902
904
|
This will produce:
|
903
905
|
|
904
906
|
```erb
|
905
|
-
<video><source src="trailer.ogg" /><source src="
|
907
|
+
<video><source src="/videos/trailer.ogg" /><source src="/videos/trailer.flv" /></video>
|
906
908
|
```
|
907
909
|
|
908
910
|
#### Linking to Audio Files with the `audio_tag`
|
@@ -39,7 +39,10 @@ Only the latest release series will receive bug fixes. When enough bugs are
|
|
39
39
|
fixed and its deemed worthy to release a new gem, this is the branch it happens
|
40
40
|
from.
|
41
41
|
|
42
|
-
|
42
|
+
In special situations, where someone from the Core Team agrees to support more series,
|
43
|
+
they are included in the list of supported series.
|
44
|
+
|
45
|
+
**Currently included series:** `4.2.Z`, `4.1.Z` (Supported by Rafael França).
|
43
46
|
|
44
47
|
Security Issues
|
45
48
|
---------------
|
@@ -54,7 +57,7 @@ be built from 1.2.2, and then added to the end of 1-2-stable. This means that
|
|
54
57
|
security releases are easy to upgrade to if you're running the latest version
|
55
58
|
of Rails.
|
56
59
|
|
57
|
-
**Currently included series:** `4.
|
60
|
+
**Currently included series:** `4.2.Z`, `4.1.Z`.
|
58
61
|
|
59
62
|
Severe Security Issues
|
60
63
|
----------------------
|
@@ -63,7 +66,7 @@ For severe security issues we will provide new versions as above, and also the
|
|
63
66
|
last major release series will receive patches and new versions. The
|
64
67
|
classification of the security issue is judged by the core team.
|
65
68
|
|
66
|
-
**Currently included series:** `4.
|
69
|
+
**Currently included series:** `4.2.Z`, `4.1.Z`, `3.2.Z`.
|
67
70
|
|
68
71
|
Unsupported Release Series
|
69
72
|
--------------------------
|
@@ -1,4 +1,4 @@
|
|
1
|
-
Rails
|
1
|
+
Rails Nested Model Forms
|
2
2
|
========================
|
3
3
|
|
4
4
|
Creating a form for a model _and_ its associations can become quite tedious. Therefore Rails provides helpers to assist in dealing with the complexities of generating these forms _and_ the required CRUD operations to create, update, and destroy associations.
|
@@ -17,9 +17,9 @@ Model setup
|
|
17
17
|
|
18
18
|
To be able to use the nested model functionality in your forms, the model will need to support some basic operations.
|
19
19
|
|
20
|
-
First of all, it needs to define a writer method for the attribute that corresponds to the association you are building a nested model form for. The `fields_for` form helper will look for this method to decide whether or not a nested model form should be
|
20
|
+
First of all, it needs to define a writer method for the attribute that corresponds to the association you are building a nested model form for. The `fields_for` form helper will look for this method to decide whether or not a nested model form should be built.
|
21
21
|
|
22
|
-
If the associated object is an array a form builder will be yielded for each object, else only a single form builder will be yielded.
|
22
|
+
If the associated object is an array, a form builder will be yielded for each object, else only a single form builder will be yielded.
|
23
23
|
|
24
24
|
Consider a Person model with an associated Address. When asked to yield a nested FormBuilder for the `:address` attribute, the `fields_for` form helper will look for a method on the Person instance named `address_attributes=`.
|
25
25
|
|
@@ -54,6 +54,9 @@ class Person < ActiveRecord::Base
|
|
54
54
|
end
|
55
55
|
```
|
56
56
|
|
57
|
+
NOTE: For greater detail on associations see [Active Record Associations](association_basics.html).
|
58
|
+
For a complete reference on associations please visit the API documentation for [ActiveRecord::Associations::ClassMethods](http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html).
|
59
|
+
|
57
60
|
### Custom model
|
58
61
|
|
59
62
|
As you might have inflected from this explanation, you _don't_ necessarily need an ActiveRecord::Base model to use this functionality. The following examples are sufficient to enable the nested model form behavior:
|
@@ -220,6 +223,6 @@ As you can see it has generated 2 `project name` inputs, one for each new `proje
|
|
220
223
|
|
221
224
|
You can basically see the `projects_attributes` hash as an array of attribute hashes, one for each model instance.
|
222
225
|
|
223
|
-
NOTE: The reason that `fields_for` constructed a
|
226
|
+
NOTE: The reason that `fields_for` constructed a hash instead of an array is that it won't work for any form nested deeper than one level deep.
|
224
227
|
|
225
228
|
TIP: You _can_ however pass an array to the writer method generated by `accepts_nested_attributes_for` if you're using plain Ruby or some other API access. See (TODO) for more info and example.
|
data/guides/source/plugins.md
CHANGED
@@ -39,13 +39,13 @@ to run integration tests using a dummy Rails application. Create your
|
|
39
39
|
plugin with the command:
|
40
40
|
|
41
41
|
```bash
|
42
|
-
$
|
42
|
+
$ rails plugin new yaffle
|
43
43
|
```
|
44
44
|
|
45
45
|
See usage and options by asking for help:
|
46
46
|
|
47
47
|
```bash
|
48
|
-
$
|
48
|
+
$ rails plugin new --help
|
49
49
|
```
|
50
50
|
|
51
51
|
Testing Your Newly Generated Plugin
|
@@ -57,7 +57,7 @@ You can navigate to the directory that contains the plugin, run the `bundle inst
|
|
57
57
|
You should see:
|
58
58
|
|
59
59
|
```bash
|
60
|
-
|
60
|
+
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips
|
61
61
|
```
|
62
62
|
|
63
63
|
This will tell you that everything got generated properly and you are ready to start adding functionality.
|
@@ -85,19 +85,19 @@ Run `rake` to run the test. This test should fail because we haven't implemented
|
|
85
85
|
|
86
86
|
```bash
|
87
87
|
1) Error:
|
88
|
-
test_to_squawk_prepends_the_word_squawk
|
89
|
-
NoMethodError: undefined method `to_squawk' for
|
90
|
-
|
88
|
+
CoreExtTest#test_to_squawk_prepends_the_word_squawk:
|
89
|
+
NoMethodError: undefined method `to_squawk' for "Hello World":String
|
90
|
+
/path/to/yaffle/test/core_ext_test.rb:5:in `test_to_squawk_prepends_the_word_squawk'
|
91
91
|
```
|
92
92
|
|
93
93
|
Great - now you are ready to start development.
|
94
94
|
|
95
|
-
In `lib/yaffle.rb`, add `require
|
95
|
+
In `lib/yaffle.rb`, add `require 'yaffle/core_ext'`:
|
96
96
|
|
97
97
|
```ruby
|
98
98
|
# yaffle/lib/yaffle.rb
|
99
99
|
|
100
|
-
require
|
100
|
+
require 'yaffle/core_ext'
|
101
101
|
|
102
102
|
module Yaffle
|
103
103
|
end
|
@@ -118,7 +118,7 @@ end
|
|
118
118
|
To test that your method does what it says it does, run the unit tests with `rake` from your plugin directory.
|
119
119
|
|
120
120
|
```bash
|
121
|
-
|
121
|
+
2 runs, 2 assertions, 0 failures, 0 errors, 0 skips
|
122
122
|
```
|
123
123
|
|
124
124
|
To see this in action, change to the test/dummy directory, fire up a console and start squawking:
|
@@ -149,7 +149,7 @@ end
|
|
149
149
|
```ruby
|
150
150
|
# yaffle/lib/yaffle.rb
|
151
151
|
|
152
|
-
require
|
152
|
+
require 'yaffle/core_ext'
|
153
153
|
require 'yaffle/acts_as_yaffle'
|
154
154
|
|
155
155
|
module Yaffle
|
@@ -196,16 +196,16 @@ When you run `rake`, you should see the following:
|
|
196
196
|
|
197
197
|
```
|
198
198
|
1) Error:
|
199
|
-
test_a_hickwalls_yaffle_text_field_should_be_last_squawk
|
199
|
+
ActsAsYaffleTest#test_a_hickwalls_yaffle_text_field_should_be_last_squawk:
|
200
200
|
NameError: uninitialized constant ActsAsYaffleTest::Hickwall
|
201
|
-
|
201
|
+
/path/to/yaffle/test/acts_as_yaffle_test.rb:6:in `test_a_hickwalls_yaffle_text_field_should_be_last_squawk'
|
202
202
|
|
203
203
|
2) Error:
|
204
|
-
test_a_wickwalls_yaffle_text_field_should_be_last_tweet
|
204
|
+
ActsAsYaffleTest#test_a_wickwalls_yaffle_text_field_should_be_last_tweet:
|
205
205
|
NameError: uninitialized constant ActsAsYaffleTest::Wickwall
|
206
|
-
|
206
|
+
/path/to/yaffle/test/acts_as_yaffle_test.rb:10:in `test_a_wickwalls_yaffle_text_field_should_be_last_tweet'
|
207
207
|
|
208
|
-
|
208
|
+
4 runs, 2 assertions, 0 failures, 2 errors, 0 skips
|
209
209
|
```
|
210
210
|
|
211
211
|
This tells us that we don't have the necessary models (Hickwall and Wickwall) that we are trying to test.
|
@@ -270,18 +270,18 @@ You can then return to the root directory (`cd ../..`) of your plugin and rerun
|
|
270
270
|
|
271
271
|
```
|
272
272
|
1) Error:
|
273
|
-
test_a_hickwalls_yaffle_text_field_should_be_last_squawk
|
274
|
-
NoMethodError: undefined method `yaffle_text_field' for #<Class:
|
275
|
-
|
276
|
-
|
273
|
+
ActsAsYaffleTest#test_a_hickwalls_yaffle_text_field_should_be_last_squawk:
|
274
|
+
NoMethodError: undefined method `yaffle_text_field' for #<Class:0x007fd105e3b218>
|
275
|
+
activerecord (4.1.5) lib/active_record/dynamic_matchers.rb:26:in `method_missing'
|
276
|
+
/path/to/yaffle/test/acts_as_yaffle_test.rb:6:in `test_a_hickwalls_yaffle_text_field_should_be_last_squawk'
|
277
277
|
|
278
278
|
2) Error:
|
279
|
-
test_a_wickwalls_yaffle_text_field_should_be_last_tweet
|
280
|
-
NoMethodError: undefined method `yaffle_text_field' for #<Class:
|
281
|
-
|
282
|
-
|
279
|
+
ActsAsYaffleTest#test_a_wickwalls_yaffle_text_field_should_be_last_tweet:
|
280
|
+
NoMethodError: undefined method `yaffle_text_field' for #<Class:0x007fd105e409c0>
|
281
|
+
activerecord (4.1.5) lib/active_record/dynamic_matchers.rb:26:in `method_missing'
|
282
|
+
/path/to/yaffle/test/acts_as_yaffle_test.rb:10:in `test_a_wickwalls_yaffle_text_field_should_be_last_tweet'
|
283
283
|
|
284
|
-
|
284
|
+
4 runs, 2 assertions, 0 failures, 2 errors, 0 skips
|
285
285
|
|
286
286
|
```
|
287
287
|
|
@@ -312,7 +312,7 @@ ActiveRecord::Base.send :include, Yaffle::ActsAsYaffle
|
|
312
312
|
When you run `rake`, you should see the tests all pass:
|
313
313
|
|
314
314
|
```bash
|
315
|
-
|
315
|
+
4 runs, 4 assertions, 0 failures, 0 errors, 0 skips
|
316
316
|
```
|
317
317
|
|
318
318
|
### Add an Instance Method
|
@@ -386,7 +386,7 @@ ActiveRecord::Base.send :include, Yaffle::ActsAsYaffle
|
|
386
386
|
Run `rake` one final time and you should see:
|
387
387
|
|
388
388
|
```
|
389
|
-
|
389
|
+
6 runs, 6 assertions, 0 failures, 0 errors, 0 skips
|
390
390
|
```
|
391
391
|
|
392
392
|
NOTE: The use of `write_attribute` to write to the field in model is just one example of how a plugin can interact with the model, and will not always be the right method to use. For example, you could also use:
|
@@ -440,5 +440,5 @@ $ bin/rake rdoc
|
|
440
440
|
|
441
441
|
* [Developing a RubyGem using Bundler](https://github.com/radar/guides/blob/master/gem-development.md)
|
442
442
|
* [Using .gemspecs as Intended](http://yehudakatz.com/2010/04/02/using-gemspecs-as-intended/)
|
443
|
-
* [Gemspec Reference](http://
|
443
|
+
* [Gemspec Reference](http://guides.rubygems.org/specification-reference/)
|
444
444
|
* [GemPlugins: A Brief Introduction to the Future of Rails Plugins](http://www.intridea.com/blog/2008/6/11/gemplugins-a-brief-introduction-to-the-future-of-rails-plugins)
|
@@ -38,9 +38,11 @@ generate(:scaffold, "person name:string")
|
|
38
38
|
route "root to: 'people#index'"
|
39
39
|
rake("db:migrate")
|
40
40
|
|
41
|
-
|
42
|
-
git
|
43
|
-
git
|
41
|
+
after_bundle do
|
42
|
+
git :init
|
43
|
+
git add: "."
|
44
|
+
git commit: %Q{ -m 'Initial commit' }
|
45
|
+
end
|
44
46
|
```
|
45
47
|
|
46
48
|
The following sections outline the primary methods provided by the API:
|
@@ -228,6 +230,22 @@ git add: "."
|
|
228
230
|
git commit: "-a -m 'Initial commit'"
|
229
231
|
```
|
230
232
|
|
233
|
+
### after_bundle(&block)
|
234
|
+
|
235
|
+
Registers a callback to be executed after the gems are bundled and binstubs
|
236
|
+
are generated. Useful for all generated files to version control:
|
237
|
+
|
238
|
+
```ruby
|
239
|
+
after_bundle do
|
240
|
+
git :init
|
241
|
+
git add: '.'
|
242
|
+
git commit: "-a -m 'Initial commit'"
|
243
|
+
end
|
244
|
+
```
|
245
|
+
|
246
|
+
The callbacks gets executed even if `--skip-bundle` and/or `--skip-spring` has
|
247
|
+
been passed.
|
248
|
+
|
231
249
|
Advanced Usage
|
232
250
|
--------------
|
233
251
|
|
@@ -18,7 +18,7 @@ Introduction to Rack
|
|
18
18
|
|
19
19
|
Rack provides a minimal, modular and adaptable interface for developing web applications in Ruby. By wrapping HTTP requests and responses in the simplest way possible, it unifies and distills the API for web servers, web frameworks, and software in between (the so-called middleware) into a single method call.
|
20
20
|
|
21
|
-
|
21
|
+
* [Rack API Documentation](http://rack.github.io/)
|
22
22
|
|
23
23
|
Explaining Rack is not really in the scope of this guide. In case you are not familiar with Rack's basics, you should check out the [Resources](#resources) section below.
|
24
24
|
|
@@ -99,6 +99,10 @@ To find out more about different `rackup` options:
|
|
99
99
|
$ rackup --help
|
100
100
|
```
|
101
101
|
|
102
|
+
### Development and auto-reloading
|
103
|
+
|
104
|
+
Middlewares are loaded once and are not monitored for changes. You will have to restart the server for changes to be reflected in the running application.
|
105
|
+
|
102
106
|
Action Dispatcher Middleware Stack
|
103
107
|
----------------------------------
|
104
108
|
|
@@ -229,7 +233,7 @@ Much of Action Controller's functionality is implemented as Middlewares. The fol
|
|
229
233
|
|
230
234
|
**`ActionDispatch::Static`**
|
231
235
|
|
232
|
-
* Used to serve static
|
236
|
+
* Used to serve static files. Disabled if `config.serve_static_files` is `false`.
|
233
237
|
|
234
238
|
**`Rack::Lock`**
|
235
239
|
|
@@ -273,7 +277,7 @@ Much of Action Controller's functionality is implemented as Middlewares. The fol
|
|
273
277
|
|
274
278
|
**`ActionDispatch::Callbacks`**
|
275
279
|
|
276
|
-
*
|
280
|
+
* Provides callbacks to be executed before and after dispatching the request.
|
277
281
|
|
278
282
|
**`ActiveRecord::Migration::CheckPending`**
|
279
283
|
|
@@ -303,7 +307,7 @@ Much of Action Controller's functionality is implemented as Middlewares. The fol
|
|
303
307
|
|
304
308
|
* Parses out parameters from the request into `params`.
|
305
309
|
|
306
|
-
**`
|
310
|
+
**`Rack::Head`**
|
307
311
|
|
308
312
|
* Converts HEAD requests to `GET` requests and serves them as so.
|
309
313
|
|