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

16 commits

Author SHA1 Message Date
Jose and Yehuda
56cdc81c08 Remove default match without specified method
In the current router DSL, using the +match+ DSL
method will match all verbs for the path to the
specified endpoint.

In the vast majority of cases, people are
currently using +match+ when they actually mean
+get+. This introduces security implications.

This commit disallows calling +match+ without
an HTTP verb constraint by default. To explicitly
match all verbs, this commit also adds a
:via => :all option to +match+.

Closes #5964
2012-04-24 22:52:26 -05:00
José Valim
180edc84f1 Override respond_to? since we are also overriding method_missing. 2012-01-03 20:26:45 +01:00
thedarkone
036f77574d Make polymorphic_url calls go through application helpers again.
This brings back the ability to overwrite/extend url generating methods in application heleprs.
2011-07-25 13:43:02 +02:00
Piotr Sarnacki
f545a5081e Fix tests, main_app mounted helper must be defined explicitly now. 2011-04-25 17:57:52 +02:00
Piotr Sarnacki
22b11a41cc Allow mounting engines at '/'
Without that commit script_name always become '/', which
results in paths like //posts/1 instead of /posts/1
2010-09-30 09:47:05 +02:00
Piotr Sarnacki
6258f7c972 Change app to main_app in mounted_helpers 2010-09-08 19:27:59 +02:00
Piotr Sarnacki
18aee33335 Do not require passing :app to mounted helpers, it's actually useless and not DRY 2010-09-08 19:27:59 +02:00
Piotr Sarnacki
1e6612ef80 Ensure that url_helpers included after application's ones have higher priority 2010-09-03 22:59:07 +02:00
Piotr Sarnacki
6c95e0f879 Add mounted_helpers to routes
mounted_helpers are a bit similar to url_helpers. They're automatically
included in controllers for Rails.application and each of mounted
Engines. Mounted helper allows to call url_for and named helpers for
given application.

Given Blog::Engine mounted as blog_engine, there are 2 helpers defined:
app and blog_engine. You can call routes for app and engine using those
helpers:

app.root_url
app.url_for(:controller => "foo")
blog_engine.posts_path
blog_engine.url_for(@post)
2010-09-03 22:59:07 +02:00
Piotr Sarnacki
e9791bec82 Routes refactoring:
* added more tests for prefix generation
* fixed bug with generating host for both prefix and url
* refactored url_for method
* organized tests for prefix generation
2010-09-03 22:59:07 +02:00
Piotr Sarnacki
229a868264 Use new url_for API instead of including routes.url_helpers 2010-09-03 22:59:06 +02:00
Piotr Sarnacki
b697ba9fd7 Added some more tests for url generation between Engine and Application 2010-09-03 22:59:06 +02:00
Piotr Sarnacki
b1e5e233fa Refactored tests for prefix generation and added test for url generation in regular class with default_url_options[:script_name] set 2010-09-03 22:59:05 +02:00
Piotr Sarnacki
eedbf87d15 New way of generating urls for Application from Engine.
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.
2010-09-03 22:59:05 +02:00
Piotr Sarnacki
451c9942bb Allow to generate Application routes inside Engine
This requires knowledge about original SCRIPT_NAME and
the parent router. It should be pass through the env
as ORIGIAL_SCRIPT_NAME and action_dispatch.parent_routes
2010-09-03 22:59:05 +02:00
Piotr Sarnacki
28016d33b0 Use env['action_dispatch.routes'] to determine if we should generate prefix or not.
This technique is here to allow using routes from Engine in Application
and vice versa. When using Engine routes inside Application it should
generate prefix based on mount point. When using Engine routes inside
Engine it should use env['SCRIPT_NAME']. In any other case it should
generate prefix as env should not be even available.
2010-09-03 22:59:05 +02:00