aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/metal/url_for.rb
Commit message (Collapse)AuthorAgeFilesLines
* Add `Style/RedundantFreeze` to remove redudant `.freeze`Yasuo Honda2018-09-291-1/+1
| | | | | | | | | | | | | | | | | | | | | Since Rails 6.0 will support Ruby 2.4.1 or higher `# frozen_string_literal: true` magic comment is enough to make string object frozen. This magic comment is enabled by `Style/FrozenStringLiteralComment` cop. * Exclude these files not to auto correct false positive `Regexp#freeze` - 'actionpack/lib/action_dispatch/journey/router/utils.rb' - 'activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb' It has been fixed by https://github.com/rubocop-hq/rubocop/pull/6333 Once the newer version of RuboCop released and available at Code Climate these exclude entries should be removed. * Replace `String#freeze` with `String#-@` manually if explicit frozen string objects are required - 'actionpack/test/controller/test_case_test.rb' - 'activemodel/test/cases/type/string_test.rb' - 'activesupport/lib/active_support/core_ext/string/strip.rb' - 'activesupport/test/core_ext/string_ext_test.rb' - 'railties/test/generators/actions_test.rb'
* Use frozen string literal in actionpack/Kir Shatrov2017-07-291-0/+2
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* [docs] fix ActionController documentationHrvoje Šimić2017-03-121-1/+1
| | | | [ci skip]
* modernizes hash syntax in actionpackXavier Noria2016-08-061-4/+4
|
* Decrease string allocations in url_optionsschneems2015-07-291-1/+5
| | | | | | The request.script_name is dup-d which allocates an extra string. It is most commonly an empty string "". We can save a ton of string allocations by checking first if the string is empty, if so we can use a frozen empty string instead of duplicating an empty string. This change buys us 35,714 bytes of memory and 893 fewer objects per request.
* Fix a few typos [ci skip]Robin Dupret2015-04-051-3/+3
|
* Fix documentation of url_for module [ci skip]Prathamesh Sonpatki2015-03-061-1/+4
| | | | | | | | | | | - The request needs to be instance of ActionDispatch::Request or an object that responds to host, optional_port, protocol and symbolized_path_parameter. - This documentation was correctly added in https://github.com/rails/rails/commit/e3b3f416b57f5642ea25078485f7e9394ad04526 but was changed to https://github.com/rails/rails/commit/e1ceae576e3911f3e6708b5d19a0e3ef63769eb7. - Fixes #16160.
* stop referencing `env` in url_forAaron Patterson2014-12-301-1/+1
| | | | | encapsulate env in the request so that we can eventually move away from the env hash
* use methods on the request rather than direct hash accessAaron Patterson2014-12-301-2/+2
| | | | this will help decouple us from using the rack env hash
* Simplify code branch, remove #tapCarlos Antonio da Silva2014-07-311-7/+6
|
* Avoid a new hash objectCarlos Antonio da Silva2014-07-311-1/+1
|
* use symbol keys for path_parametersAaron Patterson2014-05-221-1/+1
|
* we can just use Ruby hereAaron Patterson2014-05-211-2/+2
|
* do not allocate strings while creating urlsAaron Patterson2014-04-301-1/+1
|
* don't allocate string on hash accessAaron Patterson2014-04-301-1/+1
|
* Fix generating route from engine to other enginePiotr Sarnacki2013-05-031-1/+2
| | | | | | | | | | | | A regression was introduced in 5b3bb6, generating route from within an engine to an another engine resulted in prefixing a path with the SCRIPT_NAME value. The regression was caused by the fact that SCRIPT_NAME should be appended only if it's the SCRIPT_NAME for the application, not if it's SCRIPT_NAME from the current engine. closes #10409
* Multiple changes to 1,9 hash syntaxAvnerCohen2012-10-271-1/+1
|
* Fix handling SCRIPT_NAME from within mounted engine'sPiotr Sarnacki2012-08-111-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When you mount your application at a path, for example /myapp, server should set SCRIPT_NAME to /myapp. With such information, rails application knows that it's mounted at /myapp path and it should generate routes relative to that path. Before this patch, rails handled SCRIPT_NAME correctly only for regular apps, but it failed to do it for mounted engines. The solution was to hardcode default_url_options[:script_name], which is not the best answer - it will work only when application is mounted at a fixed path. This patch fixes the situation by respecting original value of SCRIPT_NAME when generating application's routes from engine and the other way round - when you generate engine's routes from application. This is done by using one of 2 pieces of information in env - current SCRIPT_NAME or SCRIPT_NAME for a corresponding router. This is because we have 2 cases to handle: - generating engine's route from application: in this situation SCRIPT_NAME is basically SCRIPT_NAME set by the server and it indicates the place where application is mounted, so we can just pass it as :original_script_name in url_options. :original_script_name is used because if we use :script_name, router will ignore generating prefix for engine - generating application's route from engine: in this situation we already lost information about the SCRIPT_NAME that server used. For example if application is mounted at /myapp and engine is mounted at /blog, at this point SCRIPT_NAME is equal /myapp/blog. Because of that we need to keep reference to /myapp SCRIPT_NAME by binding it to the current router. Later on we can extract it and use when generating url Please note that starting from now you *should not* use default_url_options[:script_name] explicitly if your server already passes correct SCRIPT_NAME to rack env. (closes #6933)
* Renamed _path_segments to _recallBogdan Gusiev2012-08-041-1/+1
|
* Removing ==Examples and last blank lines of docs from actionpackFrancesco Rodriguez2012-05-151-3/+0
|
* Clean up module docs [ci skip]Vijay Dev2012-03-071-21/+21
| | | | Removed some useless docstrings and no-doc'ed some.
* Can't cache url_options on a controller levelPiotr Sarnacki2012-03-021-11/+12
| | | | | It fails if routes from to railties are called in one context, for example: blog.posts_path and main_app.users_path
* Optimize path helpers.José Valim2012-03-021-16/+14
|
* deletes spurious arrowXavier Noria2011-08-271-1/+1
|
* minor edits after going through what's new in docrailsXavier Noria2011-05-141-4/+7
|
* added an example for AC::UrlFor usage to make usage simpler.Nick Sutterer2011-05-121-1/+13
|
* added docs for AbC::UrlFor and AC::UrlFor.Nick Sutterer2011-05-121-0/+6
|
* :subdomain, :domain and :tld_length options can now be used in url_for, ↵Josh Kalderimis2010-11-231-1/+3
| | | | | | allowing for easy manipulation of the host during link generation. Signed-off-by: José Valim <jose.valim@gmail.com>
* Do not cache the script name outcome.José Valim2010-09-271-9/+11
|
* Cache url_options on a per-request basis.thedarkone2010-09-271-9/+11
|
* Refactor ActionMailer to not use hide_actionsPiotr Sarnacki2010-09-031-14/+1
|
* Fix generating urls with mounted helpers in view contextPiotr Sarnacki2010-09-031-1/+1
| | | | | | | | | | There were actually 2 problems with this one: * script_name was added to options as a string and then it was used in RouteSet#url_for with usage of <<, which was changing the original script_name * the second issue was with _with_routes method. It was called in RoutesProxy to modify _routes in view_context, but url_helpers in views is just delegating it to controller, so another _with_routes call is needed there
* Ensure that env is always available in controllersPiotr Sarnacki2010-09-031-1/+1
|
* Added some more tests for url generation between Engine and ApplicationPiotr Sarnacki2010-09-031-4/+4
|
* Get rid of :skip_prefix options in routesPiotr Sarnacki2010-09-031-8/+4
|
* New way of generating urls for Application from Engine.Piotr Sarnacki2010-09-031-2/+11
| | | | | | | | | It's based specifying application's script_name with: Rails.application.default_url_options = {:script_name => "/foo"} default_url_options method is delegated to routes. If router used to generate url differs from the router passed via env it always overwrites :script_name with this value.
* Fixes for "router" and "routes" terminologyWincent Colaiuta2010-07-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit f7ba614c2db improved the internal consistency of the different means of accessing routes, but it introduced some problems at the level of code comments and user-visible strings. This commit applies fixes on three levels: Firstly, we remove or replace grammatically invalid constructs such as "a routes" or "a particular routes". Secondly, we make sure that we always use "the router DSL" or "the router syntax", because this has always been the official terminology. Finally, we make sure that we only use "routes" when referring to the application-specific set of routes that are defined in the "config/routes.rb" file, we use "router" when referring on a more abstract level to "the code in Rails used to handle routing", and we use "routing" when we need an adjective to apply to nouns such as "url_helpers. Again this is consistent with historical practice and other places in the documentation. Note that this is not a sweep over the entire codebase to ensure consistent usage of language; it is just a revision of the changes introduced in commit f7ba614c2db. Signed-off-by: Wincent Colaiuta <win@wincent.com> Signed-off-by: José Valim <jose.valim@gmail.com>
* Unify routes naming by renaming router to routesPiotr Sarnacki2010-07-021-4/+4
| | | | Signed-off-by: José Valim <jose.valim@gmail.com>
* Make named helpers unprotected without becoming actions [#4696 state:resolved]wycats2010-06-071-0/+8
|
* Refactor the RouteSet so it uses a Generator object instead of one huge method.wycats2010-03-091-1/+0
|
* Tweak out url_for uses :script_name and add some testsCarl Lerche2010-03-041-5/+1
|
* Get rid of relative_url_path in favor of respecting SCRIPT_NAME. Also added ↵Carlhuda2010-03-041-1/+1
| | | | a way to specify a default SCRIPT_NAME when generating URLs out of the context of a request.
* Work on deprecating ActionController::Base.relative_url_rootCarlhuda2010-03-031-0/+4
|
* Change the API for setting global options for #url_for to self.url_options = ↵Carlhuda2010-02-261-1/+1
| | | | | | { ... } This attr_accessor can be set in a before filter or in the action itself. Overwriting default_url_options still works but will output a deprecation notice.
* Rename named_url_helpers to url_helpers and url_helpers to url_forCarlhuda2010-02-261-1/+1
|
* Continued effort to deglobalize the routerCarlhuda2010-02-251-0/+21
|
* WIP: Remove the global routerCarlhuda2010-02-251-165/+0
|
* Use ActionDispatch::Routing everywhereMartin Schürrer2010-02-211-2/+2
|