1. 28 8月, 2015 2 次提交
    • X
      revises 877e42e2 · cbe7899f
      Xavier Noria 提交于
      * A string in the example lacked quotes.
      
      * The tests asserted stuff about :last_name, whereas
        test params do not have that key.
      
      * But, the first one passed, why? After hitting my head against
        the wall and doing some obscure rituals realized the new
        #require had an important typo, wanted to iterate over the
        array argument (key), but it ran over its own hash keys
        (method #keys).
      
      * Modified the test to prevent the same typo to happen again.
      
      * The second test assigned to an unused variable safe_params
        that has been therefore removed.
      
      * Grammar of the second test description.
      
      * Since I was on it, reworded both test descriptions.
      cbe7899f
    • G
      [Feature] params.require requires array of params · 877e42e2
      Gaurish Sharma 提交于
      This PR adds ability to accept arrays which allows you to require multiple values in one method. so instead of this:
      
      ```ruby
      params.require(:person).require(:first_name)
      params.require(:person).require(:last_name)
      ```
      
      Here it will be one line for each params, so say if I require 10params, it will be 10lines of repeated code which is not dry. So I have added new method which does this in one line:
      
      ```ruby
      params.require(:person).require([:first_name, :last_name])
      ```
      
      Comments welcome
      877e42e2
  2. 17 8月, 2015 1 次提交
  3. 22 7月, 2015 2 次提交
    • A
      drop conditionals in conversion logic · 5046d517
      Aaron Patterson 提交于
      there is no reason to `convert_hashes_to_parameters` with an assignemt
      flag.  The caller knows whether or not it wants the value assigned.  We
      should just change the uncommon case (not writing to the underlying
      hash) to just call the conversion method and return that value.
      5046d517
    • A
      rearrange logic to use positive branches · c75153d2
      Aaron Patterson 提交于
      only hashes are converted to parameter objects, so lets add a branch for
      them.  This also removes a is_a? test for Parameters so we can be
      abstracted from the class.
      c75153d2
  4. 19 7月, 2015 1 次提交
    • R
      Fix exception overwritten for parameters fetch method · 780af27b
      Roque Pinel 提交于
      When executing an `ActionController::Parameters#fetch` with a block
      that raises a `KeyError` the raised `KeyError` will be rescued and
      converted to an `ActionController::ParameterMissing` exception,
      covering up the original exception.
      
      [Jonas Schubert Erlandsson & Roque Pinel]
      780af27b
  5. 18 7月, 2015 7 次提交
  6. 16 7月, 2015 2 次提交
  7. 15 7月, 2015 1 次提交
    • P
      Make AC::Parameters not inherited from Hash · 14a3bd52
      Prem Sichanugrist 提交于
      This is another take at #14384 as we decided to wait until `master` is
      targeting Rails 5.0. This commit is implementation-complete, as it
      guarantees that all the public methods on the hash-inherited Parameters
      are still working (based on test case). We can decide to follow-up later
      if we want to remove some methods out from Parameters.
      14a3bd52
  8. 22 6月, 2015 2 次提交
  9. 06 4月, 2015 1 次提交
  10. 28 3月, 2015 1 次提交
    • S
      Return super in ActionController::Parameters.const_missing · 1b0526ea
      Shuhei Kagawa 提交于
      The current implementation of ActionController::Parameters.const_missing
      returns `ActionController::Parameters.always_permitted_parameters` even
      if its `super` returns a constant without raising error. This prevents its
      subclass in a autoloading module/class from taking advantage of
      autoloading constants.
      
          class SomeParameters < ActionController::Parameters
            def do_something
              DefinedSomewhere.do_something
            end
          end
      
      In the code above, `DefinedSomewhere` is to be autoloaded with
      `Module.const_missing` but `ActionController::Parameters.const_missing`
      returns `always_permitted_parameters` instead of the autoloaded
      constant.
      
      This pull request fixes the issue respecting `const_missing`'s `super`.
      1b0526ea
  11. 28 2月, 2015 1 次提交
  12. 19 12月, 2014 1 次提交
  13. 12 12月, 2014 2 次提交
  14. 29 10月, 2014 1 次提交
    • X
      let's warn with heredocs · b3bfa361
      Xavier Noria 提交于
      The current style for warning messages without newlines uses
      concatenation of string literals with manual trailing spaces
      where needed.
      
      Heredocs have better readability, and with `squish` we can still
      produce a single line.
      
      This is a similar use case to the one that motivated defining
      `strip_heredoc`, heredocs are super clean.
      b3bfa361
  15. 19 8月, 2014 5 次提交
    • P
      User `#to_hash` instead of calling `super` · 3fcbbc8a
      Prem Sichanugrist 提交于
      Ruby 1.9.3 does not implement Hash#to_h, so we can't call `super` on it.
      3fcbbc8a
    • P
      Fix failing test on several methods on Parameter · 3591dd59
      Prem Sichanugrist 提交于
      * `each`
      * `each_pair`
      * `delete`
      * `select!`
      3591dd59
    • P
      9704379c
    • P
      Add missing `Hash` methods to `AC::Parameters` · bd7f4719
      Prem Sichanugrist 提交于
      This is to make sure that `permitted` status is maintained on the
      resulting object.
      
      I found these methods that needs to be redefined by looking for
      `self.class.new` in the code.
      
      * extract!
      * transform_keys
      * transform_values
      bd7f4719
    • P
      Make `AC::Params#to_h` return Hash with safe keys · 5109740c
      Prem Sichanugrist 提交于
      `ActionController::Parameters#to_h` now returns a `Hash` with
      unpermitted keys removed. This change is to reflect on a security
      concern where some method performed on an `ActionController::Parameters`
      may yield a `Hash` object which does not maintain `permitted?` status.
      If you would like to get a `Hash` with all the keys intact, duplicate
      and mark it as permitted before calling `#to_h`.
      
          params = ActionController::Parameters.new(name: 'Senjougahara Hitagi')
          params.to_h # => {}
      
          unsafe_params = params.dup.permit!
          unsafe_params.to_h # => {"name"=>"Senjougahara Hitagi"}
      
          safe_params = params.permit(:name)
          safe_params.to_h # => {"name"=>"Senjougahara Hitagi"}
      
      This change is consider a stopgap as we cannot chage the code to stop
      `ActionController::Parameters` to inherit from
      `HashWithIndifferentAccess` in the next minor release.
      
      Also, adding a CHANGELOG entry to mention that
      `ActionController::Parameters` will not inheriting from
      `HashWithIndifferentAccess` in the next major version.
      5109740c
  16. 28 6月, 2014 1 次提交
  17. 27 6月, 2014 1 次提交
  18. 14 6月, 2014 1 次提交
  19. 07 6月, 2014 2 次提交
    • X
      f84d081f
    • X
      Revert "Convert StrongParameters cache to a hash. This fixes an unbounded" · 1ecada20
      Xavier Noria 提交于
      We cannot cache keys because arrays are mutable. We rather want to cache
      the arrays. This behaviour is tailor-made for the usage pattern strongs
      params is designed for.
      
      In a forthcoming commit I am going to add a test that covers why we need
      to cache by value.
      
      Every strong params instance has a live span of a request, the cache goes
      away with the object. Since strong params have such a concrete intention,
      it would be interesting to see if there are actually any real-world use
      cases that are an actual leak, one that practically may matter.
      
      I am not convinced that the theoretical leak has any practical consequences,
      but if it can be shown there are, then I believe we should either get rid of
      the cache (which is an optimization), or else wipe it in the mutating API.
      
      This reverts commit e63be276.
      1ecada20
  20. 06 6月, 2014 1 次提交
  21. 04 6月, 2014 1 次提交
  22. 31 3月, 2014 1 次提交
  23. 24 2月, 2014 1 次提交
  24. 24 12月, 2013 1 次提交