aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'master' of github.com:rails/docrailsVijay Dev2014-03-291-0/+4
|\
| * Mention required glob param name in match docs for mapperEarl St Sauver2014-03-201-0/+4
| | | | | | | | | | | | | | THe match documentation doesn't mention any requirement of the parameter name requirement for matches. However, including a bare glob character without a variable assignment causes a parse error.
* | Use nested_scope? not shallow? to determine whether to copy optionsAndrew White2014-03-161-1/+5
| | | | | | | | | | | | | | | | The method `shallow?` returns false if the parent resource is a singleton so we need to check if we're not inside a nested scope before copying the :path and :as options to their shallow equivalents. Fixes #14388.
* | Copy shallow options from normal options when using scopeAndrew White2014-03-081-1/+2
| | | | | | | | | | | | If the options :shallow_prefix and :shallow_path are not set in the scope options then copy them from the normal :as and :path options if they are set.
* | Pull namespace defaults out of the options hashAndrew White2014-03-081-3/+10
| | | | | | | | | | | | | | If a developer has specified either :path or :as in the options hash then these should be used as the defaults for :shallow_path and :shallow_prefix. Fixes #14241.
* | Only use shallow nested scope when depth is > 1Andrew White2014-03-081-20/+23
| | | | | | | | | | | | | | | | By tracking the depth of resource nesting we can push the need for nested shallow scoping to only those routes that are nested more than one deep. This allows us to keep the fix for #12498 and fix the regression in #14224. Fixes #14224.
* | Move setting :scope_level_resource to resource_scopeAndrew White2014-03-081-7/+7
|/ | | | | | | | Originally with_scope_level was exclusively for managing scope levels with resources, however it is now used for other things so it makes more sense to move the responsibility for setting the :scope_level_resource to the resource_scope method. This eliminates repeatedly setting it to the same resource as each resource method scope is evaluated.
* Set the :shallow_path as each scope is generatedAndrew White2014-02-091-1/+12
| | | | | | | | | | | | | | | | If we set :shallow_path when shallow is called it can result in incorrect paths if the resource is inside a namespace because namespace itself sets the :shallow_path option to the namespace path. We fix this by removing the :shallow_path option from shallow as that should only be turning shallow routes on and not otherwise affecting the scope. To do this we need to treat the :shallow option to resources differently to other scope options and move it to before the nested block is called. This change also has the positive side effect of making the behavior of the :shallow option consistent with the shallow method. Fixes #12498.
* Transform dashes to underscores in resource route namesByron Bischoff2014-01-251-4/+4
| | | | Fixes #13824
* Fix `rake routes` error when `Rails::Engine` with empty routes is mounted; ↵Maurizio De Santis2014-01-241-3/+3
| | | | | | fixes rails/rails#13810 Squash
* Automatically convert dashes to underscores in shorthand routesMikko Johansson2014-01-201-0/+1
|
* Automatically convert dashes to underscores for url helpersAmr Tamimi2014-01-201-1/+2
|
* Allow an absolute controller path inside a module scopeAndrew White2014-01-051-2/+6
| | | | Fixes #12777
* Unique the segment keys array for non-optimized url helpersAndrew White2014-01-051-1/+1
| | | | | | | | | | In Rails 3.2 you only needed pass an argument for dynamic segment once so unique the segment keys array to match the number of args. Since the number of args is less than required parts the non-optimized code path is selected. This means to benefit from optimized url generation the arg needs to be specified as many times as it appears in the path. Fixes #12808
* Show full route constraints in error messageAndrew White2014-01-051-2/+3
| | | | | | | | When an optimized helper fails to generate, show the full route constraints in the error message. Previously it would only show the contraints that were required as part of the path. Fixes #13592
* Simplify arg parameterizationAndrew White2014-01-051-6/+1
|
* Use a custom route vistor for optimized route generationAndrew White2014-01-051-27/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using a Regexp to replace dynamic segments in a path string is fraught with difficulty and can lead to odd edge cases like #13349. Since we already have a parsed representation of the path it makes sense to use that to generate an array of segments that can be used to build an optimized route's path quickly. Tests on a simple route (e.g. /posts/:id) show a speedup of 35%: https://gist.github.com/pixeltrix/8261932 Calculating ------------------------------------- Current Helper: 5274 i/100ms New Helper: 8050 i/100ms ------------------------------------------------- Current Helper: 79263.6 (±3.7%) i/s - 395550 in 4.997252s New Helper: 153464.5 (±4.9%) i/s - 772800 in 5.047834s Tests on a more complex route show even an greater performance boost: https://gist.github.com/pixeltrix/8261957 Calculating ------------------------------------- Current Helper: 2367 i/100ms New Helper: 5382 i/100ms ------------------------------------------------- Current Helper: 29506.0 (±3.2%) i/s - 149121 in 5.059294s New Helper: 78815.5 (±4.1%) i/s - 398268 in 5.062161s It also has the added benefit of fixing the edge cases described above. Fixes #13349
* Allow engine root relative redirects using an empty string.Andrew White2014-01-011-8/+18
| | | | | | | | | | | | | | | | | | Example: # application routes.rb mount BlogEngine => '/blog' # engine routes.rb get '/welcome' => redirect('') This now redirects to the path `/blog`, whereas before it would redirect to the application root path. In the case of a path redirect or a custom redirect if the path returned contains a host then the path is treated as absolute. Similarly for option redirects, if the options hash returned contains a `:host` or `:domain` key then the path is treated as absolute. Fixes #7977
* Fix method redefined warning message in mapper.rbAndrew White2013-12-291-2/+3
|
* Show routes defined under assets prefixRyunosuke SATO2013-12-191-1/+1
| | | | Closes #9625
* Add mailer previews feature based on mail_view gemAndrew White2013-12-171-1/+1
|
* Spelling and Grammar checksAkshay Vishnoi2013-12-121-1/+1
|
* Fix mounting engines inside a resources blockPiotr Sarnacki2013-12-101-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | When a route is mounted inside a resources block, it's automatically prefixed, so a following code: resources :users do mount Blog::Engine => '/blog' end will generate a user_blog path helper. In order to access engine helpers, we also use "mounted_helpers", a list of helpers associated with each mounted engine, so a path to blog's post can be generated using user_blog.post_path(user, post). The problem I'm fixing here is that mount used a raw :as option, without taking nestings into account. As a result, blog was added to a route set as a `user_blog`, but helper was generated for just `blog`. This commit applies the proper logic for defining a helper for a mounted engine nested in resources or resource block. (closes #8533)
* Try to escape each part of a path redirect route correctlyAndrew White2013-12-021-8/+25
| | | | | | | | | | | | | A path redirect may contain any and all parts of a url which have different escaping rules for each part. This commit tries to escape each part correctly by splitting the string into three chunks - path (which may also include a host), query and fragment; then it applies the correct escape pattern to each part. Whilst using `URI.parse` would be better, unfortunately the possible presence of %{name} parameters in the path redirect string prevents us from using it so we have to use a regular expression instead. Fixes #13110.
* Merge remote-tracking branch 'docrails/master'Xavier Noria2013-11-241-1/+1
|\ | | | | | | | | | | Conflicts: activesupport/lib/active_support/core_ext/hash/deep_merge.rb activesupport/lib/active_support/core_ext/hash/keys.rb
| * Change syntax format for example returned valuesPrem Sichanugrist2013-11-111-1/+1
| | | | | | | | | | | | | | | | | | According to our guideline, we leave 1 space between `#` and `=>`, so we want `# =>` instead of `#=>`. Thanks to @fxn for the suggestion. [ci skip]
* | Fix for routes taskSıtkı Bağdat2013-11-211-1/+2
| | | | | | | | This commit fixes formatting issue for `rake routes` task, when a section is shorter than a header.
* | Avoid hash lookups for building an array of required defaultsCarlos Antonio da Silva2013-11-151-2/+3
| | | | | | | | Only set the value once after it's calculated.
* | Get rid of useless temp variableCarlos Antonio da Silva2013-11-151-2/+1
| |
* | Set values instead of building hashes with single values for mergingCarlos Antonio da Silva2013-11-151-2/+2
| |
* | Take Hash with options inside Array in #url_forAndrey Ognevsky2013-11-151-0/+2
| |
* | avoiding next statementsAkshay Vishnoi2013-11-151-9/+12
| |
* | Improve Errors when Controller Name or Action isn't specfiedGaurish Sharma2013-11-051-2/+4
|/ | | | | | | | | | These errors occur when, there routes are wrongly defined. example, the following line would cause a missing :action error root "welcomeindex" Mostly beginners are expected to hit these errors, so lets improve the error message a bit to make their learning experience bit better.
* Respect `SCRIPT_NAME` when using `redirect` with a relative pathAndrew White2013-10-101-0/+18
| | | | | | | | | | | | | | | | Example: # application routes.rb mount BlogEngine => '/blog' # engine routes.rb get '/admin' => redirect('admin/dashboard') This now redirects to the path `/blog/admin/dashboard`, whereas before it would've generated an invalid url because there would be no slash between the host name and the path. It also allows redirects to work where the application is deployed to a subdirectory of a website. Fixes #7977
* Merge branch 'master' of github.com:rails/docrailsVijay Dev2013-09-281-1/+1
|\
| * Fix link_to return valueEarl J St Sauver2013-09-221-1/+1
| | | | | | | | | | | | The documentation is showing the link_to method as just returning the contents of the url_for method. It should be returning an "<a>" tag with the correct href set.
* | Merge pull request #10773 from wangjohn/link_and_routing_optionsRafael Mendonça França2013-09-231-0/+13
|\ \ | | | | | | | | | Adding documentation and tests to ``polymorphic_url`` and ``link_to``
| * | Adding documentation to +polymorphic_url+wangjohn2013-06-131-0/+13
| | | | | | | | | | | | | | | | | | | | | concerning the options that it inherits from +url_for+. The way that +polymorhpic_url+ is built allows it to have options like +:anchor+, +:script_name+, etc. but this is currently not documented.
* | | Merge pull request #12216 from suginoy/a-anRafael Mendonça França2013-09-132-2/+2
|\ \ \ | | | | | | | | Fix typos: the indefinite articles(a -> an).
| * | | Fix typos: the indefinite articles(a -> an)SUGINO Yasuhiro2013-09-132-2/+2
| | | |
* | | | Revert "Merge pull request #12208 from mjhoy/patch-1"Rafael Mendonça França2013-09-121-0/+4
| |_|/ |/| | | | | | | | | | | | | | | | | | | | This reverts commit ab5cd54b7e791f8419f689d1bef5394890268a6f, reversing changes made to cdc10c898d4865302740340eedec4f5f4ca76565. Reason: This way of defining root path is still supported. See https://github.com/rails/rails/blob/d262773ab7f0aae5de2d354ac2eca168e95b653d/actionpack/test/controller/routing_test.rb#L450-457
* | | Merge branch 'master' of github.com:rails/docrailsVijay Dev2013-09-131-10/+10
|\ \ \
| * | | Change documentation to consistently refer to the same objectEarl J St Sauver2013-09-081-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | The documentation in this section is referring to a profile, so the resource that's created should probably also be a profile of some sort.
| * | | Blacklist refferenced in docs is actually whitelistEarl J St Sauver2013-09-081-2/+2
| |/ / | | | | | | | | | | | | | | | The docs refference a blacklist, but really what's being described is a whitelist. Anything that matches the constraint gets through to the path.
* | | remove outdated docsMichael Hoy2013-09-121-4/+0
| | |
* | | Refactor handling of action normalizationMax Shytikov2013-09-101-11/+13
| | | | | | | | | | | | | | | | | | Reference: Bloody mess internals http://gusiev.com/slides/rails_contribution/static/#40
* | | Update mapper documenation for match helper [ci skip]Earl St Sauver2013-08-301-2/+3
|/ / | | | | | | | | | | | | | | This piece of documentation is out of date. The use of match without any via option is prevented, now the HTTP verbs have to be explicitly set. If they're not set then the error message in normalize_conditions! (around line 186) is shown.
* | Revert "Merge branch 'master' of github.com:rails/docrails"Vijay Dev2013-08-171-13/+11
| | | | | | | | | | | | | | This reverts commit 70d6e16fbad75b89dd1798ed697e7732b8606fa3, reversing changes made to ea4db3bc078fb3093ecdddffdf4f2f4ff3e1e8f9. Seems to be a code merge done by mistake.
* | Refactor handling of action normalizationMax Shytikov2013-07-261-11/+13
| | | | | | | | | | | | Reference: Bloody mess internals http://gusiev.com/slides/rails_contribution/static/#40
* | Refactor to reduce number of loopsAndrew White2013-07-171-15/+25
| | | | | | | | | | | | Only build the missing_keys array once we have detected that there actually are missing keys by moving the check to be part of the block that performs the path substitution.