1. 05 1月, 2015 2 次提交
  2. 06 11月, 2014 1 次提交
  3. 19 10月, 2014 3 次提交
  4. 18 10月, 2014 1 次提交
    • C
      Replace (slower) block.call with (faster) yield · 6aa115e4
      claudiob 提交于
      Performance optimization: `yield` with an implicit `block` is faster than `block.call`.
      See http://youtu.be/fGFM_UrSp70?t=10m35s and the following benchmark:
      
      ```ruby
      require 'benchmark/ips'
      
      def fast
       yield
      end
      
      def slow(&block)
       block.call
      end
      
      Benchmark.ips do |x|
       x.report('fast') { fast{} }
       x.report('slow') { slow{} }
      end
      
      # => fast    154095 i/100ms
      # => slow     71454 i/100ms
      # =>
      # => fast  7511067.8 (±5.0%) i/s -   37445085 in   4.999660s
      # => slow  1227576.9 (±6.8%) i/s -    6145044 in   5.028356s
      ```
      6aa115e4
  5. 18 8月, 2014 4 次提交
  6. 09 8月, 2014 1 次提交
  7. 17 6月, 2014 1 次提交
  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. 27 12月, 2013 1 次提交
    • Ł
      Add any/all support for variants · a288cc1e
      Łukasz Strzałkowski 提交于
      Like `format.any`, you can do the same with variants.
      
      It works for both inline:
      
          respond_to do |format|
            format.html.any   { render text: "any"   }
            format.html.phone { render text: "phone" }
          end
      
      and block syntax:
      
          respond_to do |format|
            format.html do |variant|
              variant.any(:tablet, :phablet){ render text: "any" }
              variant.phone { render text: "phone" }
            end
          end
      a288cc1e
  11. 18 12月, 2013 1 次提交
    • G
      Some assorted fixes for the 4.1 release notes: · 2003d040
      Godfrey Chan 提交于
      * Added release notes for secrets.yml and mentioned it in the highlights
      * Added release notes for Mailer previews and mentioned it in the highlights
      * Added release notes for Module#concerning
      * Removed mention for AV extraction from the highlights
      * Rearranged the major features to put highlighted features first
      * Various improvements and typo fixes
      
      [ci skip]
      2003d040
  12. 12 12月, 2013 1 次提交
  13. 10 12月, 2013 2 次提交
    • Ł
      Inline variants syntax · edacdbfa
      Łukasz Strzałkowski 提交于
      In most cases, when setting variant specific code, you're not sharing any code
      within format.
      
      Inline syntax can vastly simplify defining variants in those situations:
      
        respond_to do |format|
          format.js { render "trash" }
          format.html do |variant|
            variant.phone { redirect_to progress_path }
            variant.none  { render "trash" }
          end
        end
      
      Becomes:
      
        respond_to do |format|
          format.js         { render "trash" }
          format.html.phone { redirect_to progress_path }
          format.html.none  { render "trash" }
        end
      edacdbfa
    • Ł
      Simplify @responses hash initialization · fbb6be50
      Łukasz Strzałkowski 提交于
      @responses hash needs to be initialized with mime types that we get from
      Collector#collect_mimes_from_class_level. Mime::Type class as key and nil as
      value. This need to happen before content negotiation. Before that, it was
      looping though mime types and executing mime-type-generated method inside
      collector (see
      AbstractController::Collector#generate_method_for_mime). That approach resulted
      in 2 unnecessary method calls for each mime type
      collected by Collector#collect_mimes_from_class_level.
      
      Now hash is initialized in place, without usage of Collector#custom method.
      fbb6be50
  14. 09 12月, 2013 3 次提交
    • D
      Revert "Merge pull request #13235 from strzalek/variants-inline" -- needs a little more work! · 4aae538d
      David Heinemeier Hansson 提交于
      This reverts commit 18616114, reversing
      changes made to cad9eb17.
      4aae538d
    • Ł
      Inline variants syntax · 2647d2f6
      Łukasz Strzałkowski 提交于
      In most cases, when setting variant specific code, you're not sharing any code
      within format.
      
      Inline syntax can vastly simplify defining variants in those sitiations:
      
        respond_to do |format|
          format.js { render "trash" }
          format.html do |variant|
            variant.phone { redirect_to progress_path }
            variant.none  { render "trash" }
          end
        end
      `
      Becomes:
      
        respond_to do |format|
          format.js         { render "trash" }
          format.html.phone { redirect_to progress_path }
          format.html.none  { render "trash" }
        end
      2647d2f6
    • Ł
      Simplify @responses hash initialization · 9b8c0ff3
      Łukasz Strzałkowski 提交于
      @responses hash needs to be initialized with mime types that we get from
      Collector#collect_mimes_from_class_level. Mime::Type class as key and nil as
      value. This need to happen before content negotiation. Before that, it was
      looping though mime types and executing mime-type-generated method inside
      collector (see
      AbstractController::Collector#generate_method_for_mime). That approach resulted
      in 2 unnecessary method calls for each mime type
      collected by Collector#collect_mimes_from_class_level.
      
      Now hash is initialized in place, without usage of Collector#custom method.
      9b8c0ff3
  15. 08 12月, 2013 2 次提交
  16. 04 12月, 2013 3 次提交
    • 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
    • C
      Add nodoc to added VariantFilter class · bc26f442
      Carlos Antonio da Silva 提交于
      bc26f442
    • Ł
      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
  17. 15 11月, 2013 2 次提交
  18. 11 11月, 2013 1 次提交
  19. 09 10月, 2013 1 次提交
  20. 09 9月, 2013 1 次提交
  21. 25 2月, 2013 1 次提交
  22. 01 2月, 2013 1 次提交
  23. 07 1月, 2013 1 次提交
  24. 03 1月, 2013 1 次提交
  25. 02 1月, 2013 1 次提交
  26. 02 12月, 2012 2 次提交