1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
Commit graph

13 commits

Author SHA1 Message Date
Bernerd Schaefer
ee63532d40 url_for does not modify polymorphic options
The `url_for` methods in `actionpack` and `actionview`
now make a copy of the provided options
before generating polymorphic paths or URLs.

The bug in the previous behavior
is most noticeable in a case like:

    url_options = [:new, :post, param: 'value']

    if current_page?(url_options)
      css_class = "active"
    end

    link_to "New Post", url_options, class: css_class
2015-09-04 13:42:32 -07:00
Prem Sichanugrist
14a3bd520d Make AC::Parameters not inherited from Hash
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.
2015-07-15 11:11:36 -04:00
Aaron Patterson
cad20f720c move _generate_paths_by_default to where it is used
_generate_paths_by_default wasn't used in AD::Routing::UrlFor, so we
should be able to move it where it is used in AV::Routing
2015-03-01 13:35:24 -08:00
Xavier Noria
9685080a76 let mailer templates generate URLs by default [Xavier Noria, Richard Schneeman] 2014-11-24 14:33:50 -08:00
schneems
4d47220d7c Perf optimization for url_for called w/ Hash
Benchmarking the existing code:

```ruby
{ :only_path => options[:host].nil? }.merge!(options.symbolize_keys)) 
```

Against optimized code, that does not require a new hash or a merge:

```ruby
options = options.symbolize_keys
options[:only_path] = options[:host].nil? unless options.key?(:only_path)
options
```

We see a statistically significant performance gain:

![](https://www.dropbox.com/s/onocpc0zfw4kjxl/Screenshot%202014-08-14%2012.45.30.png?dl=1)

Updated to not mutate incoming parameters
2014-08-14 12:46:06 -05:00
Aaron Patterson
cfdda38088 use the helper method builder to construct helper methods 2014-05-12 15:54:45 -07:00
Aaron Patterson
9656640080 probably should not check in a raise 2014-05-12 15:54:45 -07:00
Aaron Patterson
74a6ad2c6b undo optimized calls until the builder object is finished 2014-05-12 15:54:45 -07:00
Aaron Patterson
89e0718188 fix url_for with classes 2014-05-12 15:54:44 -07:00
Aaron Patterson
4b8ab797b4 break each polymorphic type to it's own method 2014-05-12 15:54:44 -07:00
Aaron Patterson
fd92437112 split nil / Hash cases in url_for
this reduces the number of comparisons and method calls `url_for`
requires.  The nil case no longer calls `symbolize_keys`, we already
know options is nil, so no more ||=, and since it is nil we already know
that options[:host] will be nil too.
2014-04-30 10:56:55 -07:00
Andrey Ognevsky
d04c4fac3b Take Hash with options inside Array in #url_for 2013-11-15 15:50:42 +04:00
Piotr Sarnacki
0d6e8edc2a Move actionpack/lib/action_view* into actionview/lib 2013-06-20 17:23:15 +02:00
Renamed from actionpack/lib/action_view/routing_url_for.rb (Browse further)