1. 31 5月, 2016 2 次提交
  2. 24 5月, 2016 1 次提交
  3. 19 5月, 2016 1 次提交
  4. 16 5月, 2016 1 次提交
    • J
      Action Mailer: Declarative exception handling with `rescue_from`. · e35b98e6
      Jeremy Daer 提交于
      Follows the same pattern as controllers and jobs. Exceptions raised in
      delivery jobs (enqueued by `#deliver_later`) are also delegated to the
      mailer's rescue_from handlers, so you can handle the DeserializationError
      raised by delivery jobs:
      
      ```ruby
      class MyMailer < ApplicationMailer
        rescue_from ActiveJob::DeserializationError do
          …
        end
      ```
      
      ActiveSupport::Rescuable polish:
      * Add the `rescue_with_handler` class method so exceptions may be
        handled at the class level without requiring an instance.
      * Rationalize `exception.cause` handling. If no handler matches the
        exception, fall back to the handler that matches its cause.
      * Handle exceptions raised elsewhere. Pass `object: …` to execute
        the `rescue_from` handler (e.g. a method call or a block to
        instance_exec) against a different object. Defaults to `self`.
      e35b98e6
  5. 13 5月, 2016 1 次提交
  6. 12 5月, 2016 1 次提交
  7. 11 5月, 2016 1 次提交
  8. 07 5月, 2016 2 次提交
  9. 06 5月, 2016 1 次提交
    • R
      Implement helpers proxy in controller instance level · 541a51ec
      Rafael Mendonça França 提交于
      It is a common pattern in the Rails community that when people want to
      :xa
      use any kind of helper that is defined inside app/helpers they includes
      the helper module inside the controller like:
      
          module UserHelper
            def my_user_helper
              # ...
            end
          end
      
          class UsersController < ApplicationController
            include UserHelper
      
            def index
              render inline: my_user_helper
            end
          end
      
      This has problem because the helper can't access anything that is
      defined in the view level context class.
      
      Also all public methods of the helper become available in the controller
      what can lead to undesirable methods being routed and behaving as
      actions.
      
      Also if you helper depends on other helpers or even Action View helpers
      you need to include each one of these dependencies in your controller
      otherwise your helper is not going to work.
      
      We already have a helpers proxy at controller class level but that proxy
      doesn't have access to the instance variables defined in the
      controller.
      
      With this new instance level helper proxy users can reuse helpers in the
      controller without having to include the modules and with access to
      instance variables defined in the controller.
      
          class UsersController < ApplicationController
            def index
              render inline: helpers.my_user_helper
            end
          end
      541a51ec
  10. 05 5月, 2016 1 次提交
  11. 29 4月, 2016 1 次提交
  12. 27 4月, 2016 1 次提交
  13. 24 4月, 2016 1 次提交
  14. 21 4月, 2016 1 次提交
  15. 20 4月, 2016 1 次提交
  16. 18 4月, 2016 2 次提交
  17. 15 4月, 2016 1 次提交
  18. 12 4月, 2016 1 次提交
  19. 04 4月, 2016 1 次提交
    • R
      Fixes #24239 · f9910680
      Ryan T. Hosford 提交于
        - skip calling helper_method if it's not there: if we don't have helpers, we needn't define one.
        - tests that an api controller can include and use ActionController::Cookies
      f9910680
  20. 01 4月, 2016 1 次提交
    • J
      Strong ETag validators · c1c9c690
      Jeremy Daer 提交于
      * Introduce `Response#strong_etag=` and `#weak_etag=` and analogous options
        for `fresh_when` and `stale?`. `Response#etag=` sets a weak ETag.
      
        Strong ETags are desirable when you're serving byte-for-byte identical
        responses that support Range requests, like PDFs or videos (typically
        done by reproxying the response from a backend storage service).
        Also desirable when fronted by some CDNs that support strong ETags
        only, like Akamai.
      
      * No longer strips quotes (`"`) from ETag values before comparing them.
        Quotes are significant, part of the ETag. A quoted ETag and an unquoted
        one are not the same entity.
      
      * Support `If-None-Match: *`. Rarely useful for GET requests; meant
        to provide some optimistic concurrency control for PUT requests.
      c1c9c690
  21. 14 3月, 2016 1 次提交
    • R
      Fixes #23964 · b43158af
      Ryan T. Hosford 提交于
        - Adds #each_chunk to ActionDispatch::Response. it's a method which
          will be called by ActionDispatch::Response#each.
        - Make Response#each a proper method instead of delegating to @stream
        - In Live, instead of overriding #each, override #each_chunk.
        - `#each` should just spit out @str_body if it's already set
        - Adds #test_set_header_after_read_body_during_action
          to prove this fixes #23964
        - Adds #test_each_isnt_called_if_str_body_is_written to
          ensure #each_chunk is not called when @str_body is available
        - Call `@response.sent!` in AC::TestCase's #perform so a test response
          acts a bit more like a real response. Makes test that call  `#assert_stream_closed`
          pass again.
        - Additionally assert `#committed?` in `#assert_stream_closed`
        - Make test that was calling @response.stream.each pass again by
          calling @response.each instead.
      b43158af
  22. 12 3月, 2016 1 次提交
    • S
      Use the most highest priority exception handler when cause is set · b76b8176
      Sean Griffin 提交于
      There was some subtle breakage caused by #18774, when we removed
      `#original_exception` in favor of `#cause`. However, `#cause` is
      automatically set by Ruby when raising an exception from a rescue block.
      With this change, we will use whichever handler has the highest priority
      (whichever call to `rescue_from` came last). In cases where the outer
      has lower precidence than the cause, but the outer is what should be
      handled, cause will need to be explicitly unset.
      
      Fixes #23925
      b76b8176
  23. 10 3月, 2016 1 次提交
    • S
      Add `ActionController::Parameters#dig` · 5cd2beb0
      Sean Griffin 提交于
      This method will only be added when used with Ruby 2.3.0 or greater.
      This method has the same behavior as `Hash#dig`, except it will convert
      hashes to `ActionController::Parameters`, similar to `#[]` and `#fetch`.
      5cd2beb0
  24. 09 3月, 2016 1 次提交
  25. 05 3月, 2016 1 次提交
  26. 04 3月, 2016 2 次提交
    • S
      Do not destructively mutate passed options hash in route definitions · fea7c9fe
      Sam Davies 提交于
      - Fixes #24030
      
      An example scope might be specified as such:
      
      ```ruby
      HTML = { constraints: { format: :html } }.freeze
      scope HTML do
        get 'x'
      end
      ```
      
      This currently raises an error because the mapper attempts to
      destructively modify the passed options hash. This is dangerous because
      this options hash might even be shared with other scopes.
      
      We should instead always instantiate a new object instead of modifying
      the passed options.
      fea7c9fe
    • K
      Rename constrain_to to exclude. · 49331322
      Kasper Timm Hansen 提交于
      `ActionDispatch::SSL` redirects all HTTP requests to HTTPS, not just some.
      The `constrain_to` option inverts this, so it sounds like the middleware
      only handles a few requests, rather than the majority with a few routes to
      opt out of the redirect.
      
      Renaming to `exclude` matches this intent more closely.
      49331322
  27. 02 3月, 2016 1 次提交
  28. 01 3月, 2016 2 次提交
    • M
      Publish AS::Executor and AS::Reloader APIs · d3c9d808
      Matthew Draper 提交于
      These should allow external code to run blocks of user code to do
      "work", at a similar unit size to a web request, without needing to get
      intimate with ActionDipatch.
      d3c9d808
    • A
      Deprecate :controller and :action path parameters · 6520ea5f
      Andrew White 提交于
      Allowing :controller and :action values to be specified via the path
      in config/routes.rb has been an underlying cause of a number of issues
      in Rails that have resulted in security releases. In light of this it's
      better that controllers and actions are explicitly whitelisted rather
      than trying to blacklist or sanitize 'bad' values.
      6520ea5f
  29. 29 2月, 2016 1 次提交
  30. 28 2月, 2016 1 次提交
  31. 26 2月, 2016 2 次提交
  32. 25 2月, 2016 3 次提交
    • J
      Render default template if block doesn't render · 48f140cf
      Justin Coyne 提交于
      When a `respond_to` collector doesn't have a response, then a
      `:no_content` response should be rendered. This brings the default
      rendering behavior introduced by
      https://github.com/rails/rails/issues/19036 to controller methods
      employing `respond_to`
      48f140cf
    • K
      Additional review of 6b317617. · 46cb45df
      Kasper Timm Hansen 提交于
      * Fixes typos in error message and release notes.
      * Removes unused template test file.
      46cb45df
    • G
      Lock down new `ImplicitRender` behavior for 5.0 RC · 73b1efc5
      Godfrey Chan 提交于
      1. Conceptually revert #20276
      
         The feature was implemented for the `responders` gem. In the end,
         they did not need that feature, and have found a better fix (see
         plataformatec/responders#131).
      
         `ImplicitRender` is the place where Rails specifies our default
         policies for the case where the user did not explicitly tell us
         what to render, essentially describing a set of heuristics. If
         the gem (or the user) knows exactly what they want, they could
         just perform the correct `render` to avoid falling through to
         here, as `responders` did (the user called `respond_with`).
      
         Reverting the patch allows us to avoid exploding the complexity
         and defining “the fallback for a fallback” policies.
      
      2. `respond_to` and templates are considered exhaustive enumerations
      
         If the user specified a list of formats/variants in a `respond_to`
         block, anything that is not explicitly included should result
         in an `UnknownFormat` error (which is then caught upstream to
         mean “406 Not Acceptable” by default). This is already how it
         works before this commit.
      
         Same goes for templates – if the user defined a set of templates
         (usually in the file system), that set is now considered exhaustive,
         which means that “missing” templates are considered `UnknownFormat`
         errors (406).
      
      3. To keep API endpoints simple, the implicit render behavior for
         actions with no templates defined at all (regardless of formats,
         locales, variants, etc) are defaulted to “204 No Content”. This
         is a strictly narrower version of the feature landed in #19036 and
         #19377.
      
      4. To avoid confusion when interacting in the browser, these actions
         will raise an `UnknownFormat` error for “interactive” requests
         instead. (The precise definition of “interactive” requests might
         change – the spirit here is to give helpful messages and avoid
         confusions.)
      
      Closes #20666, #23062, #23077, #23564
      
      [Godfrey Chan, Jon Moss, Kasper Timm Hansen, Mike Clark, Matthew Draper]
      73b1efc5