diff options
Diffstat (limited to 'guides')
-rw-r--r-- | guides/source/active_support_core_extensions.md | 6 | ||||
-rw-r--r-- | guides/source/documents.yaml | 1 | ||||
-rw-r--r-- | guides/source/getting_started.md | 3 | ||||
-rw-r--r-- | guides/source/layouts_and_rendering.md | 36 |
4 files changed, 40 insertions, 6 deletions
diff --git a/guides/source/active_support_core_extensions.md b/guides/source/active_support_core_extensions.md index c857f30541..ba839e1723 100644 --- a/guides/source/active_support_core_extensions.md +++ b/guides/source/active_support_core_extensions.md @@ -3873,7 +3873,7 @@ def default_helper_module! module_name = name.sub(/Controller$/, '') module_path = module_name.underscore helper module_path -rescue MissingSourceFile => e +rescue LoadError => e raise e unless e.is_missing? "helpers/#{module_path}_helper" rescue NameError => e raise e unless e.missing_name? "#{module_name}Helper" @@ -3885,7 +3885,7 @@ NOTE: Defined in `active_support/core_ext/name_error.rb`. Extensions to `LoadError` ------------------------- -Active Support adds `is_missing?` to `LoadError`, and also assigns that class to the constant `MissingSourceFile` for backwards compatibility. +Active Support adds `is_missing?` to `LoadError`. Given a path name `is_missing?` tests whether the exception was raised due to that particular file (except perhaps for the ".rb" extension). @@ -3896,7 +3896,7 @@ def default_helper_module! module_name = name.sub(/Controller$/, '') module_path = module_name.underscore helper module_path -rescue MissingSourceFile => e +rescue LoadError => e raise e unless e.is_missing? "helpers/#{module_path}_helper" rescue NameError => e raise e unless e.missing_name? "#{module_name}Helper" diff --git a/guides/source/documents.yaml b/guides/source/documents.yaml index 134e9ddad2..52de98ee52 100644 --- a/guides/source/documents.yaml +++ b/guides/source/documents.yaml @@ -85,6 +85,7 @@ description: This guide provides you with all you need to get started in creating, enqueueing and executing background jobs. - name: Testing Rails Applications + work_in_progress: true url: testing.html description: This is a rather comprehensive guide to the various testing facilities in Rails. It covers everything from 'What is a test?' to the testing APIs. Enjoy. - diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md index e803f95911..03a4703cb8 100644 --- a/guides/source/getting_started.md +++ b/guides/source/getting_started.md @@ -2039,9 +2039,6 @@ What's Next? Now that you've seen your first Rails application, you should feel free to update it and experiment on your own. -We recommend next that you read [A Guide to Testing Rails Applications](testing.html), -for a deep dive into Rails testing facilities and approaches. - Remember you don't have to do everything without help. As you need assistance getting up and running with Rails, feel free to consult these support resources: diff --git a/guides/source/layouts_and_rendering.md b/guides/source/layouts_and_rendering.md index 6bf17b4a98..c3cde49630 100644 --- a/guides/source/layouts_and_rendering.md +++ b/guides/source/layouts_and_rendering.md @@ -1030,6 +1030,42 @@ One way to use partials is to treat them as the equivalent of subroutines: as a Here, the `_ad_banner.html.erb` and `_footer.html.erb` partials could contain content that is shared among many pages in your application. You don't need to see the details of these sections when you're concentrating on a particular page. +As you already could see from the previous sections of this guide, `yield` is a very powerful tool for cleaning up your layouts. Keep in mind that it's pure ruby, so you can use it almost everywhere. For example, we can use it to DRY form layout definition for several similar resources: + +* `users/index.html.erb` + + ```html+erb + <%= render "shared/search_filters", search: @q do |f| %> + <p> + Name contains: <%= f.text_field :name_contains %> + </p> + <%= end %> + ``` + +* `roles/index.html.erb` + + ```html+erb + <%= render "shared/search_filters", search: @q do |f| %> + <p> + Title contains: <%= f.text_field :title_contains %> + </p> + <%= end %> + ``` + +* `shared/_search_filters.html.erb` + + ```html+erb + <%= form_for(@q) do |f| %> + <h1>Search form:</h1> + <fieldset> + <%= yield f %> + </fieldset> + <p> + <%= f.submit "Search" %> + </p> + <% end %> + ``` + TIP: For content that is shared among all pages in your application, you can use partials directly from layouts. #### Partial Layouts |