Commit Graph

63 Commits

Author SHA1 Message Date
Pat Allan
acea68de02 Adding frozen_string_literal pragma to Railties. 2017-08-14 19:08:09 +02:00
yuuji.yaginuma
65a1733545 Fix warning: method redefined;
This fixes the following warning:

```
/tmp/d20170727-7039-kmdtb1/app/app/models/user.rb:5: warning: method redefined; discarding old model_name
rails/activemodel/lib/active_model/naming.rb:222: warning: previous definition of model_name was here
```
2017-07-28 12:18:14 +09:00
Matthew Draper
87b3e226d6 Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"
This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing
changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
2017-07-02 02:15:17 +09:30
Kir Shatrov
cfade1ec7e Enforce frozen string in Rubocop 2017-07-01 02:11:03 +03:00
Andrew White
d7c1e62c2c Split direct method into two
Use a separate method called `resolve` for the custom polymorphic
mapping to clarify the API.
2017-02-21 15:30:48 +00:00
Andrew White
c116eaf221 Prefer remove_method over undef_method
Using `undef_method` means that when a route is removed any other
implementations of that method in the ancestor chain are inaccessible
so instead use `remove_method` which restores access to the ancestor.
2017-02-21 15:30:47 +00:00
Andrew White
3bf47b018b Add custom polymorphic mapping
Allow the use of `direct` to specify custom mappings for polymorphic_url, e.g:

  resource :basket
  direct(class: "Basket") { [:basket] }

This will then generate the following:

  >> link_to "Basket", @basket
  => <a href="/basket">Basket</a>

More importantly it will generate the correct url when used with `form_for`.

Fixes #1769.
2017-02-21 15:30:47 +00:00
Andrew White
47a27e8950 Rename url_helper to direct 2017-02-21 15:30:46 +00:00
Andrew White
ce7d5fb2e6 Add support for defining custom url helpers in routes.rb
Allow the definition of custom url helpers that will be available
automatically wherever standard url helpers are available. The
current solution is to create helper methods in ApplicationHelper
or some other helper module and this isn't a great solution since
the url helper module can be called directly or included in another
class which doesn't include the normal helper modules.

Reference #22512.
2017-02-21 15:30:46 +00:00
Rafael Mendonça França
79a5ea9ead
Remove deprecated support to :text in render 2016-10-10 00:02:52 -03:00
Rafael Mendonça França
55f9b8129a
Add three new rubocop rules
Style/SpaceBeforeBlockBraces
Style/SpaceInsideBlockBraces
Style/SpaceInsideHashLiteralBraces

Fix all violations in the repository.
2016-08-16 04:30:11 -03:00
Xavier Noria
477568ee33 modernizes hash syntax in railties 2016-08-06 19:38:55 +02:00
Xavier Noria
783763bde9 applies new string literal convention in railties/test
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 19:16:09 +02:00
Prathamesh Sonpatki
d93427840e
Remove unused boot_rails method and it's usage
- The `boot_rails` method from abstract_unit.rb is empty after 2abcdfd978fdcd491576a237e8c6b.
- So let's remove it and its usage.
2016-07-04 09:34:21 +05:30
Nicholas Firth-McCoy
9d513e0a19 Fix rails/info routes for apps with globbing route
The /rails/info routes were inaccessible in apps with a catch-all
globbing route, as they were being appended after the globbing route and
would never be matched.

See also ccc3ddb7762bae0df7e2f8d643b19b6a4769d5be.
2016-06-20 21:49:12 +10:00
Genadi Samokovarov
38492590cf Introduce new welcome page for new projects
As requested by David in 23233.
2016-01-26 00:27:49 +02:00
eileencodes
0ce3b97fa3 Fix test that was failing because of typo
Here `app` needed to be `get` because we're getting a route. This fixes
the typo so the test passes.
2015-09-27 11:39:32 -04:00
Aditya Kapoor
b5e82d99ef Add missing routing tests for info controller
Vaguely related to #21605 where I proposed to remove index route since it was redirecting to the 'routes' action,

but this was kept so I thought it made sense to add some tests regarding this.
2015-09-27 12:49:20 +05:30
Jean Boussier
f413cbee8d Pure rack apps can be mounted with a name
See 9b15828b5c (commitcomment-8764492)
2014-11-29 09:24:43 -05:00
Piotr Sarnacki
73bbf54868 Revert "Match Dev/Prod parity for Index Page"
Showing welcome page in production can expose information, which should
not be visible on production if people don't override the default root
route.

This reverts commit b0caea29c2da9f4c8bb958019813482da297067d.
2013-07-22 17:19:07 +02:00
Piotr Sarnacki
230d2f84a1 Merge pull request #11514 from schneems/schneems/dev-prod-parity-index
Match Dev/Prod parity for Index Page
2013-07-22 03:25:27 -07:00
Andrew White
e5275f9b59 Clear named routes when routes.rb is reloaded
Fix an issue where Journey was failing to clear the named routes hash when the
routes were reloaded and since it doesn't overwrite existing routes then if a
route changed but wasn't renamed it kept the old definition. This was being
masked by the optimised url helpers so it only became apparent when passing an
options hash to the url helper.
2013-07-21 17:11:52 +01:00
schneems
b0caea29c2 Match Dev/Prod parity for Index Page
With Rails 4 the default index page was moved from a static file `index.html` inside the `public/` folder to an internal controller/view inside of the railties gem. This was to allow use of erb in the default index page and to remove the requirement that new apps must delete a static file to make their index pages work. While this was a good change, the functionality was unexpected to developers who wish to get their apps running in production ASAP. They will create a new app `rails new my app`, start a server to verify it works, then immediately deploy the app to verify that it can start working in production. Unfortunately locally they see a page when they visit `localhost:3000` when they visit their production app they get an error page.

We initially anticipated this problem in the original pull request, but did not properly anticipate the severity or quantity of people who would like this functionality. Having a default index page serves as an excellent litmus test for a passed deploy on default apps, and it is very unexpected to have a page work locally, but not on production. 

This change makes the default index page available in production if the developer has not over-written it by defining their own `root` path inside of routes.
2013-07-20 14:56:10 -05:00
wangjohn
bb4378404d Removing use of subclassed application constant and instead using the
more agnostic Rails.application syntax. This means tests will be more
portable, and won't rely on the existence of a particular subclass.
2013-06-03 21:38:17 -07:00
Aaron Patterson
94e68e7ad3 adding a test for root path in the app 2013-04-17 11:20:12 -07:00
Andrew White
01d3a36bfe Clear url helper methods when routes are reloaded
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.
2012-12-14 13:22:36 +00:00
schneems
baea5d69be Use Rails to Render Default Index Page
This is an alternative implementation to #7771 thanks to the advice of @spastorino

Rails is a dynamic framework that serves a static index.html by default. One of my first questions ever on IRC was solved by simply deleting my public/index.html file. This file is a source of confusion when starting as it over-rides any set "root" in the routes yet it itself is not listed in the routes. By making the page dynamic by default we can eliminate this confusion.

This PR moves the static index page to an internal controller/route/view similar to `rails/info`. When someone starts a rails server, if no root is defined, this route will take over and the "dynamic" index page from rails/welcome_controller will be rendered. These routes are only added in development. If a developer defines a root in their routes, it automatically takes precedence over this route and will be rendered, with no deleting of files required. 

In addition to removing this source of confusion for new devs, we can now use Rails view helpers to build and render this page. While not the primary intent, the added value of "dogfooding" should not be under-estimated.

The prior PR #7771 had push-back since it introduced developer facing files. This PR solves all of the same problems, but does not have any new developer facing files (it actually removes one). 

cc/ @wsouto, @dickeyxxx, @tyre, @ryanb, @josevalim, @maxim, @subdigital, @steveklabnik

ATP Railties and Actionpack.
2012-12-10 16:15:04 -08:00
Andrew White
af73e3cb15 Revert "Invert precedence of content in ActionDispatch::Static"
This reverts commit c59734f756b79c39486c45273d2cc5d42cd0c864.
2012-12-07 06:02:43 +00:00
Andrew White
c59734f756 Invert precedence of content in ActionDispatch::Static
This commit inverts the precedence in ActionDispatch::Static so that
dynamic content will be served before static content. This is so that
precompiled assets do not inadvertently get included when running in
development mode - it should have no effect in production where static
files are usually handled by the web server.

Closes #6421
2012-12-06 17:20:53 +00:00
Robin Dupret
5ad7f8ab41 Use Ruby 1.9 Hash syntax in railties 2012-10-14 18:26:58 +02:00
José Valim
5e7d6bba79 Revert "Allow loading external route files from the router"
This reverts commit 6acebb38bc0637bc05c19d87f8767f16ce79189b.

Usage of this feature did not reveal any improvement in existing apps.

Conflicts:

	actionpack/lib/action_dispatch/routing/mapper.rb
	guides/source/routing.textile
	railties/lib/rails/engine.rb
	railties/lib/rails/paths.rb
	railties/test/paths_test.rb
2012-06-29 17:44:10 +02:00
schneems
c3e3102904 Rails::InfoController tests passing
This includes new tests for /rails/info/routes
2012-05-24 12:50:16 -05:00
Carlos Antonio da Silva
2dab86c43c Define only writer method for queue, as reader is declared
Remove deprecation warning of method redefined.
2012-04-28 12:45:32 -03:00
Yehuda Katz
363a06f351 Routes reloader knows how to reload external files 2012-04-25 22:45:56 -05:00
Jose and Yehuda
6acebb38bc Allow loading external route files from the router
This feature enables the ability to load an
external routes file from the router via:
  draw :filename

External routes files go in +config/routes+. This
feature works in both engines and applications.
2012-04-25 16:07:17 -05:00
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
Aaron Patterson
8f309e3105 convert railties to use AS::TestCase 2012-01-05 17:30:17 -08:00
Aaron Patterson
c5a91d0288 should be using a / in this route rather than a # 2011-08-31 16:12:26 -07:00
Jon Leighton
62570e8626 Solve the RAILS_ENV problem in the railties tests in a more generic way 2011-06-06 13:54:05 +01:00
José Valim
80bf68aa1b prepend the assets route instead of appending, closes #436 2011-05-08 12:59:04 +02:00
José Valim
7b0c592e38 reload_routes! is part of the public API and should not be removed. 2010-10-02 17:45:26 +02:00
José Valim
609849a0f1 Fix a routing test. Reorganize middleware tests. 2010-10-02 17:42:36 +02:00
Aaron Patterson
92cb0b8be6 third parameter for rack must respond to each 2010-09-22 15:20:19 -07:00
Carl Lerche
7418a44096 Add RouteSet#append
Allows specifying blocks to the routeset that will get 	appended after the RouteSet is drawn.
2010-09-17 12:05:40 -07:00
Piotr Sarnacki
11710c0d7d Fix routing test
Signed-off-by: Mikel Lindsaar <raasdnil@gmail.com>
2010-09-11 23:26:17 +10:00
Piotr Sarnacki
36fcb776dd Fix warning by removing |map| from routes.draw 2010-09-08 19:28:00 +02:00
Piotr Sarnacki
e6b93fa6db Removed deprecated router API from railties 2010-09-05 13:44:37 +02:00
José Valim
48bf667a8b Ensure routes are loaded only after the initialization process finishes, ensuring all configuration options were applied. 2010-09-02 12:54:21 +02:00
wycats
6767946374 Improve best_standards_support to use only IE=Edge in development mode 2010-08-09 11:48:31 -07:00
wycats
123eb25fd1 Add a header that tells Internet Explorer (all versions) to use the best available standards support. This ensures that IE doesn't go into quirks mode because it has been blacklisted by too many users pressing the incompatible button. It also tells IE to use the ChromeFrame renderer, if the user has installed the plugin.
This guarantees that the best available standards support will be used on the client.
2010-07-27 19:25:07 -07:00