1. 29 9月, 2015 2 次提交
  2. 05 9月, 2015 1 次提交
    • A
      stop inheriting from Rack::Request · 529136d6
      Aaron Patterson 提交于
      Just include the modules necessary in the Request object to implement
      the things we need.  This should make it easier to build delegate
      request objects because the API is smaller
      529136d6
  3. 22 8月, 2015 2 次提交
  4. 25 3月, 2015 2 次提交
    • G
      Add ActiveSupport::ArrayInquirer and Array#inquiry · c64b99ec
      George Claghorn 提交于
      Wrapping an array in an `ArrayInquirer` gives a friendlier way to check its
      string-like contents. For example, `request.variant` returns an `ArrayInquirer`
      object. To check a request's variants, you can call:
      
          request.variant.phone?
          request.variant.any?(:phone, :tablet)
      
      ...instead of:
      
          request.variant.include?(:phone)
          request.variant.any? { |v| v.in?([:phone, :tablet]) }
      
      `Array#inquiry` is a shortcut for wrapping the receiving array in an
      `ArrayInquirer`:
      
          pets = [:cat, :dog]
          pets.cat?    # => true
          pets.ferret? # => false
          pets.any?(:cat, :ferret} # => true
      c64b99ec
    • G
      Provide friendlier access to request variants · 9d9cc477
      George Claghorn 提交于
      Closes #18933.
      9d9cc477
  5. 16 12月, 2014 1 次提交
    • T
      allow reseting of request variants · e1fb3483
      Timo Schilling 提交于
      The current implementation of `variants=` don't allow a resetting to nil, wich is the default value.
      
      This results in the following code smell:
      ```ruby
      case request.user_agent
      when /iPhone/
        request.variants = :phone
      when /iPad/
        request.variants = :ipad
      end
      ```
      
      With the ability to reset variants to nil, it could be:
      ```ruby
      request.variants = case request.user_agent
      when /iPhone/
        :phone
      when /iPad/
        :ipad
      end
      ```
      e1fb3483
  6. 19 5月, 2014 1 次提交
    • J
      Upgraded rack · adffea62
      Jarmo Isotalo 提交于
      As Rack has some non backwards compatible changes added required
      modifications to keep behaviour in rails close to same as before.
      
      Also modified generators to include rack/rack for not yet released
      version of rack
      adffea62
  7. 15 4月, 2014 1 次提交
    • R
      Return null type format when format is not know · 4d21e496
      Rafael Mendonça França 提交于
      When requesting a controller with the following code with a unknown format:
      
          def my_action
            respond_to do |format|
              format.json { head :ok }
              format.any { render text: 'Default response' }
            end
          end
      
      we should render the default response instead of raising ActionController::UnknownFormat
      
      Fixes #14462
      
      Conflicts:
      	actionpack/CHANGELOG.md
      	actionpack/test/controller/mime/respond_with_test.rb
      
      Conflicts:
      	actionpack/CHANGELOG.md
      4d21e496
  8. 14 2月, 2014 1 次提交
  9. 13 2月, 2014 1 次提交
    • L
      Variant negotiation · f9b6b865
      Lukasz Strzalkowski 提交于
      Allow setting `request.variant` as an array - an order in which they will be
      rendered.
      
      For example:
      
        request.variant = [:tablet, :phone]
      
        respond_to do |format|
          format.html.none
          format.html.phone # this gets rendered
        end
      f9b6b865
  10. 24 12月, 2013 1 次提交
    • C
      Move the null mime type to request.format · 618d5317
      Carlos Antonio da Silva 提交于
      TLDR: always return an object that responds to the query methods from
      request.format, and do not touch Mime::Type[] lookup to avoid bugs.
      
      ---
      
      Long version:
      
      The initial issue was about being able to do checks like
      request.format.html? for request with an unknown format, where
      request.format would be nil.
      
      This is where the issue came from at first in #7837 and #8085
      (merged in cba05887), but the
      implementation went down the path of adding this to the mime type
      lookup logic.
      
      This unfortunately introduced subtle bugs, for instance in the merged
      commit a test related to send_file had to be changed to accomodate the
      introduction of the NullType.
      
      Later another bug was found in #13064, related to the content-type being
      shown as #<Mime::NullType:...> for templates with localized extensions
      but no format included. This one was fixed in #13133, merged in
      43962d6e.
      
      Besides that, custom handlers were not receiving the proper template
      formats anymore when passing through the rendering process, because of
      the NullType addition. That was found while migrating an application
      from 3.2 to 4.0 that uses the Markerb gem (a custom handler that
      generates both text and html emails from a markdown template).
      
      ---
      
      This changes the implementation moving away from returning this null
      object from the mime lookup, and still fixes the initial issue where
      request.format.zomg? would raise an exception for unknown formats due to
      request.format being nil.
      618d5317
  11. 04 12月, 2013 2 次提交
    • C
      Improve a couple exception messages related to variants and mime types · 3b40a5d8
      Carlos Antonio da Silva 提交于
      Avoid one-liner conditionals when they are too big. Avoid concatenating
      strings to build error messages. Improve messages a bit.
      3b40a5d8
    • Ł
      Action Pack Variants · 2d3a6a0c
      Łukasz Strzałkowski 提交于
      By default, variants in the templates will be picked up if a variant is set
      and there's a match. The format will be:
      
        app/views/projects/show.html.erb
        app/views/projects/show.html+tablet.erb
        app/views/projects/show.html+phone.erb
      
      If request.variant = :tablet is set, we'll automatically be rendering the
      html+tablet template.
      
      In the controller, we can also tailer to the variants with this syntax:
      
        class ProjectsController < ActionController::Base
          def show
            respond_to do |format|
              format.html do |html|
                @stars = @project.stars
      
                html.tablet { @notifications = @project.notifications }
                html.phone  { @chat_heads    = @project.chat_heads }
              end
      
              format.js
              format.atom
            end
          end
        end
      
      The variant itself is nil by default, but can be set in before filters, like
      so:
      
        class ApplicationController < ActionController::Base
          before_action do
            if request.user_agent =~ /iPad/
              request.variant = :tablet
            end
          end
        end
      
      This is modeled loosely on custom mime types, but it's specifically not
      intended to be used together. If you're going to make a custom mime type,
      you don't need a variant. Variants are for variations on a single mime
      types.
      2d3a6a0c
  12. 04 3月, 2013 1 次提交
  13. 17 1月, 2013 1 次提交
  14. 08 12月, 2012 1 次提交
  15. 15 8月, 2012 1 次提交
  16. 24 5月, 2012 1 次提交
    • V
      Revert "Remove blank trailing comments" · 1ad0b378
      Vijay Dev 提交于
      This reverts commit fa6d921e.
      
      Reason: Not a fan of such massive changes. We usually close such changes
      if made to Rails master as a pull request. Following the same principle
      here and reverting.
      
      [ci skip]
      1ad0b378
  17. 20 5月, 2012 1 次提交
    • H
      Remove blank trailing comments · fa6d921e
      Henrik Hodne 提交于
      For future reference, this is the regex I used: ^\s*#\s*\n(?!\s*#). Replace
      with the first match, and voilà! Note that the regex matches a little bit too
      much, so you probably want to `git add -i .` and go through every single diff
      to check if it actually should be changed.
      fa6d921e
  18. 23 4月, 2012 1 次提交
  19. 20 7月, 2011 1 次提交
  20. 03 5月, 2011 1 次提交
  21. 23 11月, 2010 3 次提交
  22. 21 11月, 2010 2 次提交
  23. 28 8月, 2010 1 次提交
  24. 02 4月, 2010 1 次提交
    • P
      Slightly less annoying check for acceptable mime_types. This allows Accept:... · dc5300ad
      Paul Sadauskas 提交于
      Slightly less annoying check for acceptable mime_types. This allows Accept: application/json, application/jsonp (and the like), but still blacklists browsers. Essentially, we use normal content negotiation unless you include */* in your list, in which case we assume you're a browser and send HTML [#3541 state:resolved]
      dc5300ad
  25. 29 3月, 2010 1 次提交
  26. 10 3月, 2010 1 次提交
  27. 16 1月, 2010 1 次提交