aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing/route_set.rb
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* Fix failing test missed for the past year :(Andrew White2013-07-171-2/+17
| | | | | | | | | When optimized path helpers were re-introduced in d7014bc the test added in a328f2f broke but no-one noticed because it wasn't being run by the test suite. Fix the test by checking for nil values or empty strings after the args have been parameterized.
* Fix named routing regression from 3.2.13schneems2013-05-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | When named route that is nested is used in 3.2.13 Example `routes.rb`: ``` resources :nested do resources :builder, :controller => 'nested/builder' end ``` In 3.2.12 and 3.2.12 this named route would work: ``` nested_builder_path(:last_step, :nested_id => "foo") ``` Generating a url that looks like `/nested/foo/builder/last_step`. This PR fixes the regression when building urls via the optimized helper. Any explicit keys set in the options are removed from the list of implicitly mapped keys. Not sure if this is exactly how the original version worked, but this fixes this use case regression.
* Duplicate options before mutating themAndrew White2013-04-181-3/+4
|
* Mark unused variables and make some style fixesAgis Anastasopoulos2013-04-081-1/+1
| | | | It'd be a nice convention to mark the unused variables like this, now that Ruby 2 will issue no warnings for such vars being unused.
* fix wrong argument error messageVipul A M2013-03-311-1/+1
|
* Tweak exception message to avoid giving potentially misleading suggestionsTrevor Turk2013-03-201-2/+3
|
* Raise an ArgumentError when a clashing named route is definedTrevor Turk2013-03-191-1/+8
|
* Use custom visitor class for optimized url helpersAndrew White2013-03-031-9/+1
| | | | | | | | Rather than trying to use gsub to remove the optional route segments, which will fail with nested optional segments, use a custom visitor class that returns a empty string for group nodes. Closes #9524
* allow non-String default params in the router.Yves Senn2013-02-261-0/+2
| | | | | | | Closes #9435. Skip valid encoding checks for non-String parameters that come from the matched route's defaults.
* Missing or unneeded require extract_optionsAkira Matsuda2013-02-011-0/+1
|
* remove dead codeAaron Patterson2013-01-301-4/+1
|
* change parameter name for positional argsAaron Patterson2013-01-301-2/+1
|
* nodoc the helper classes, cache stuff for optimized helperAaron Patterson2013-01-301-13/+17
|
* cache path parts in the instanceAaron Patterson2013-01-301-2/+3
|
* stop evaling a string every timeAaron Patterson2013-01-301-4/+4
|
* moving helper classes outside the private blockAaron Patterson2013-01-301-90/+88
|
* pushing specialization down to the optimized classAaron Patterson2013-01-301-23/+25
|
* use polymorphism to remove conditionalAaron Patterson2013-01-301-35/+27
|
* move conditionals to instanceAaron Patterson2013-01-301-6/+16
|
* pull stuff out of the caller and hide in the instanceAaron Patterson2013-01-301-4/+3
|
* moving more stuff on to the instanceAaron Patterson2013-01-301-18/+18
|
* move optimize_helper? to the helper instanceAaron Patterson2013-01-301-9/+12
|
* moving more stuff to the instanceAaron Patterson2013-01-301-6/+6
|
* moving some stuff to the initializerAaron Patterson2013-01-301-14/+38
|
* moved more evald codeAaron Patterson2013-01-301-8/+7
|
* factored out some of the dynamic codeAaron Patterson2013-01-301-19/+31
|
* use the helpers list rather than getting the methods from the moduleAaron Patterson2013-01-241-1/+1
|
* module_eval is not necessary hereAaron Patterson2013-01-241-3/+1
|
* don't need to eval everythingAaron Patterson2013-01-241-1/+1
|
* Change the behavior of route defaultsAndrew White2013-01-151-1/+1
| | | | | | | | | | | | | | | | | | | This commit changes route defaults so that explicit defaults are no longer required where the key is not part of the path. For example: resources :posts, bucket_type: 'posts' will be required whenever constructing the url from a hash such as a functional test or using url_for directly. However using the explicit form alters the behavior so it's not required: resources :projects, defaults: { bucket_type: 'projects' } This changes existing behavior slightly in that any routes which only differ in their defaults will match the first route rather than the closest match. Closes #8814
* Raise correct exception now Journey is integrated.Andrew White2013-01-151-4/+2
| | | | | | | Now that Journey has been integrated into ActionDispatch we can raise the exception ActionController::UrlGenerationError directly rather than raising the internal Journey::Router::RoutingError and then have ActionDispatch::Routing::RouteSet#generate re-raise the exception.
* Integrate Journey into Action DispatchAndrew White2012-12-191-1/+1
| | | | | | | | Move the Journey code underneath the ActionDispatch namespace so that we don't pollute the global namespace with names that may be used for models. Fixes rails/journey#49.
* Merge pull request #8510 from thedarkone/thread_safety_improvementsAaron Patterson2012-12-141-8/+4
|\ | | | | Thread safety improvements
| * Replace some global Hash usages with the new thread safe cache.thedarkone2012-12-141-8/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary of the changes: * Add thread_safe gem. * Use thread safe cache for digestor caching. * Replace manual synchronization with ThreadSafe::Cache in Relation::Delegation. * Replace @attribute_method_matchers_cache Hash with ThreadSafe::Cache. * Use TS::Cache to avoid the synchronisation overhead on listener retrieval. * Replace synchronisation with TS::Cache usage. * Use a preallocated array for performance/memory reasons. * Update the controllers cache to the new AS::Dependencies::ClassCache API. The original @controllers cache no longer makes much sense after @tenderlove's changes in 7b6bfe84f3 and f345e2380c. * Use TS::Cache in the connection pool to avoid locking overhead. * Use TS::Cache in ConnectionHandler.
* | Clear url helper methods when routes are reloadedAndrew White2012-12-141-0/+6
| | | | | | | | | | Remove all the old url helper methods when clear! is called on the route set because it's possible that some routes have been removed.
* | Revert "Clear url helpers when reloading routes"Andrew White2012-12-141-1/+0
|/ | | | | | | | | | This doesn't actually remove old url helper methods as they are defined in a different module. This reverts commit 96bcef947bf713b7d9fc88f26dff69f568111262. Conflicts: actionpack/CHANGELOG.md
* Clear url helpers when reloading routesSantiago Pastorino2012-11-021-0/+1
|
* 1.9 hash syntax changes to docsAvnerCohen2012-10-311-6/+6
|
* Use internal instance variable naming scheme for mounted URL helper proxiesSam Pohlenz2012-09-091-1/+1
|
* refactor route_set `generate_extras` functionalityschneems2012-08-281-17/+9
| | | | | | The result of Generator with or without the @extras instance variable set contains the desired information. Rather than preserving state when initializing the original object, we can simply extract the keys from the resultant parameters. ATP Actionpack, railties
* Add Missing Keys from Journey on failed URL formatschneems2012-08-281-4/+4
| | | | | | | | | | | | | | | | | | | | | | | Many named routes have keys that are required to successfully resolve. If a key is left off like this: <%= link_to 'user', user_path %> This will produce an error like this: No route matches {:action=>"show", :controller=>"users"} Since we know that the :id is missing, we can add extra debugging information to the error message. No route matches {:action=>"show", :controller=>"users"} missing required keys: [:id] This will help new and seasoned developers look closer at their parameters. I've also subclassed the routing error to be clear that this error is a result of attempting to generate a url and not because the user is trying to visit a bad url. While this may sound trivial this error message is misleading and confuses most developers. The important part isn't what's in the options its's what's missing. Adding this information to the error message will make debugging much more obvious. This is the sister pull request of https://github.com/rails/journey/pull/44 which will be required to get they missing keys into the correct error message. Example Development Error in Rails: http://cl.ly/image/3S0T0n1T3421
* Further refactor build_conditions in route setCarlos Antonio da Silva2012-08-101-5/+3
| | | | | Return the conditions from the keep_if call, and ignore the value argument since it's not being used.
* Fix handling SCRIPT_NAME from within mounted engine'sPiotr Sarnacki2012-08-111-5/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* RouteSet: refactor internalsBogdan Gusiev2012-08-101-10/+7
| | | | | No need to build valid_conditions array. We can get all the data in place.
* RouteSet: cleanup some unneeded compexityBogdan Gusiev2012-08-041-16/+7
|
* Renamed _path_segments to _recallBogdan Gusiev2012-08-041-2/+2
|
* Simplify logical statementBogdan Gusiev2012-08-041-4/+2
|