Commit Graph

179 Commits

Author SHA1 Message Date
Charlie Somerville
94331729a1 rename SprocketsApp here to RackApp to not confuse me when grepping 2014-09-15 14:35:17 +10:00
Andrew White
b0c65978ab Use old style hash syntax for 3-2-stable 2013-06-25 12:24:06 +01:00
Andrew White
622e4ab424 Fix shorthand routes where controller and action are in the scope
Merge `:action` from routing scope and assign endpoint if both `:controller`
and `:action` are present. The endpoint assignment only occurs if there is
no `:to` present in the options hash so should only affect routes using the
shorthand syntax (i.e. endpoint is inferred from the the path).

Fixes #9856

Backport of 37b4276
2013-06-25 11:00:19 +01:00
Carlos Antonio da Silva
0c1558d32f Use 1.8 hash style 2013-02-22 14:42:35 -03:00
Yves Senn
a72dab0b6a determine the match shorthand target early.
Backport #9361.
Closes #7554.

This patch determines the `controller#action` directly
in the `match` method when the shorthand syntax is used.
this prevents problems with namespaces and scopes.
2013-02-22 09:04:04 +01:00
Andrew White
431759614d Duplicate possible frozen string from route
Ruby 1.9 freezes Hash string keys by default so where a route is
defined like this:

get 'search' => 'search'

then the Mapper will derive the action from the key. This blows up
later when the action is added to the parameters hash and the
encoding is forced.

Closes #3429
2013-01-21 17:20:51 +00:00
Andrew White
0c7a236f30 Refactor Generator class to not rely on in-place editing the controller 2012-11-16 21:44:24 -02:00
Nikita Beloglazov
09c4dfa06b Fix bug when url_for changes controller. 2012-11-16 21:44:18 -02:00
Rafael Mendonça França
190dddf231 Add test to avoid regression of 4a86362 2012-11-02 18:10:46 -02:00
Rafael Mendonça França
4a8636264d Revert "Merge pull request #7668 from Draiken/fix_issue_6497"
This reverts commit 61d5d2d8a9.

Conflicts:
	actionpack/CHANGELOG.md

REASON: This added a backward incompatible change.
2012-11-02 14:33:20 -02:00
Rafael Mendonça França
3b5bc8d71b Merge pull request #7789 from senny/7777_resource_functions_modify_options
resource and resources do no longer modify passed options
2012-10-01 12:53:53 -03:00
Rafael Mendonça França
61d5d2d8a9 Merge pull request #7668 from Draiken/fix_issue_6497
Removing to_shorthand to fix #6497
Conflicts:
	actionpack/CHANGELOG.md
2012-09-19 10:10:00 -03:00
Andrew White
71d274dbbb Add support for optional root segments containing slashes
Optional segments with a root scope need to have the leading slash
outside of the parentheses, otherwise the generated url will be empty.
However if the route has non-optional elements then the leading slash
needs to remain inside the parentheses otherwise the generated url
will have two leading slashes, e.g:

Blog::Application.routes.draw do
  get '/(:category)', :to => 'posts#index', :as => :root
  get '/(:category)/author/:name', :to => 'posts#author', :as => :author
end

$ rake routes
  root GET /(:category)(.:format)              posts#index
author GET (/:category)/author/:name(.:format) posts#author

This change adds support for optional segments that contain a slash,
allowing support for urls like /page/2 for the root path, e.g:

Blog::Application.routes.draw do
  get '/(page/:page)', :to => 'posts#index', :as => :root
end

$ rake routes
root GET /(page/:page)(.:format) posts#index

Fixes #7073
(cherry picked from commit d8745decaf59aad32aa2f09abdba99b8d0e48b31)
2012-07-17 20:09:28 +01:00
Andrew White
66e338aa98 Don't ignore nil positional arguments for url helpers - fixes #6196. 2012-05-10 22:13:04 +01:00
Andrew White
7c7fb3a862 Reset the request parameters after a constraints check
A callable object passed as a constraint for a route may access the request
parameters as part of its check. This causes the combined parameters hash
to be cached in the environment hash. If the constraint fails then any subsequent
access of the request parameters will be against that stale hash.

To fix this we delete the cache after every call to `matches?`. This may have a
negative performance impact if the contraint wraps a large number of routes as the
parameters hash is built by merging GET, POST and path parameters.

Fixes #2510.
(cherry picked from commit 56030506563352944fed12a6bb4793bb2462094b)
2012-05-03 00:00:19 +01:00
Andrew White
6cad407623 Restore interpolation of path option in redirect routes 2012-04-29 22:51:04 +01:00
Andrew White
b608cdd64c Escape interpolated params when redirecting - fixes #5688 2012-04-29 21:19:18 +01:00
Rafael Mendonça França
27fc6ec95e Fix the redirect when it receive blocks with arity of 1.
Closes #5677
2012-03-31 17:59:21 +02:00
kennyj
39d4617033 Fix some warnings on 3-2-stable 2012-02-21 12:43:41 +09:00
Aaron Patterson
73fcbaaa78 Merge pull request #4988 from kennyj/fix_4720-3
Fix GH #4720. Routing problem with nested namespace and already camelized controller option.
2012-02-10 10:01:06 -08:00
José Valim
ab44418881 Merge pull request #4908 from kennyj/fix_3864
Fix url_for method's behavior. GH #3684.
2012-02-06 17:03:42 +01:00
Paul McMahon
22980e0c17 Test for unicode path support
This is currently broken due to a bug in journey.
2012-01-25 15:27:33 +09:00
Aaron Patterson
f9275e54e0 Merge pull request #4462 from spohlenz/fix-routing-tests
Stub ip method of alternative request class in router tests
2012-01-16 09:42:07 -08:00
Aaron Patterson
50af25ba87 last named route wins. fixes #4164
This differs from route recognition where first recognized route wins.
This will not be supported in Rails 4.0 so that route recognition and
generation rules are consistent.
2011-12-28 16:33:40 -08:00
José Valim
192e55c38e Do not raise an exception if an invalid route was generated automatically. 2011-12-16 10:45:59 +01:00
José Valim
0f4da5b393 Fix failing AP tests. 2011-12-13 15:45:16 +01:00
Aaron Patterson
99d94f126d Refactoring the redirect method for the router api. 2011-11-18 10:51:12 -08:00
Aaron Patterson
0809c675ef remove the :path feature to redirects, since it cannot work 2011-11-18 10:51:11 -08:00
Aaron Patterson
4589b2419b require that all blocks have arity of 2 2011-11-18 10:51:11 -08:00
Jeremy Kemper
401d00d296 Symbol captures may generate multiple path segments, so don't escape / -> %2F. Test splat escaping. 2011-10-13 21:42:15 -07:00
Jeremy Kemper
45ced7e1be Failing tests for path parameter escaping 2011-10-13 19:02:58 -07:00
Diego Carrion
8f863742e3 allow shorthand routes with nested optional parameters 2011-10-10 19:53:42 -03:00
Pawel Pierzchala
019eea4a38 Fix named routes modifying arguments 2011-09-22 09:57:00 +02:00
Andrew Kaspick
61579b7661 when calling url_for with a hash, additional (likely unwanted) values (such as :host) would be returned in the hash... calling #dup on the hash prevents this 2011-08-11 13:28:31 -05:00
Dave Rogers
4dc42f5353 Ensure the constraints block is only applied to the correct route
addresses issue #1907 - any routes that follow a route with a constraints
  block are inheriting the previous route's constraints.
2011-07-25 09:59:53 -07:00
Prem Sichanugrist
733bfa63f5 Remove #among? from Active Support
After a long list of discussion about the performance problem from using varargs and the reason that we can't find a great pair for it, it would be best to remove support for it for now.

It will come back if we can find a good pair for it. For now, Bon Voyage, `#among?`.
2011-04-13 20:25:28 +08:00
David Heinemeier Hansson
d1575ae1b9 Change Object#either? to Object#among? -- thanks to @jamesarosen for the suggestion! 2011-04-12 00:23:07 +02:00
Prem Sichanugrist
d6edaeeaf8 Fix failing test case on master
It turned out that I overlook at some replacements ..
2011-04-10 22:40:21 -07:00
Prem Sichanugrist
a9f3c9da01 Using Object#in? and Object#either? in various places
There're a lot of places in Rails source code which make a lot of sense to switching to Object#in? or Object#either? instead of using [].include?.
2011-04-11 03:17:09 +08:00
Andrew White
e00867bc43 Raise ArgumentError if route name is invalid [#6517 state:resolved] 2011-03-06 07:08:50 +00:00
Andrew White
ccc678b49e Add test to prevent regression on namespace root nested in a resource
[#6389 state:resolved]
2011-02-14 06:12:22 +00:00
Andrew White
460a341682 Fix named route helper for routes nested inside deeply nested resources
[#6416 state:resolved]
2011-02-14 02:56:09 +00:00
german
adbae9aab8 fixed bug with nested resources within shallow scope
[#6372 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-02-04 17:07:51 -02:00
Josh Kalderimis
1e26bda095 Added documentation explaining the new additional supported syntaxes for the routing redirect method, a small changelog note, and two extra tests for path interpolation when using the hash option syntax. 2010-11-30 17:55:33 +01:00
Josh Kalderimis
0bda6f1ec6 The redirect routing method now allows for a hash of options which only changes the relevant parts of the url, or an object which responds to call can be supplied so common redirect rules can be easily reused. This commit includes a change where url generation from parts has been moved to AD::Http::URL as a class method. 2010-11-30 16:36:01 +01:00
José Valim
731ca00b48 Dynamically generaeted helpers on collection should not clobber resources url helper [#6028 state:resolved] 2010-11-25 11:50:29 +01:00
Andrew White
d446392f76 Add additional HTTP request methods from the following RFCs:
* Hypertext Transfer Protocol -- HTTP/1.1
  http://www.ietf.org/rfc/rfc2616.txt)

* HTTP Extensions for Distributed Authoring -- WEBDAV
  http://www.ietf.org/rfc/rfc2518.txt

* Versioning Extensions to WebDAV
  http://www.ietf.org/rfc/rfc3253.txt

* Ordered Collections Protocol (WebDAV)
  http://www.ietf.org/rfc/rfc3648.txt

* Web Distributed Authoring and Versioning (WebDAV) Access Control Protocol
  http://www.ietf.org/rfc/rfc3744.txt

* Web Distributed Authoring and Versioning (WebDAV) SEARCH
  http://www.ietf.org/rfc/rfc5323.txt

* PATCH Method for HTTP
  http://www.ietf.org/rfc/rfc5789.txt

[#2809 state:resolved] [#5895 state:resolved]
2010-11-02 10:56:14 +00:00
José Valim
f63d35fba5 Ensure that named routes do not overwrite previously defined routes. 2010-09-29 14:24:32 +02:00
Emilio Tagua
0cb1d87cd5 Remove duplicated test. 2010-09-27 11:19:22 -03:00
Carlos Antonio da Silva
7fc1edd790 Remove deprecated stuff in ActionController
This removes all deprecated classes in ActionController related to
Routing, Abstract Request/Response and Integration/IntegrationTest.
All tests and docs were changed to ActionDispatch instead of ActionController.
2010-09-26 02:13:45 +08:00