Commit Graph

526 Commits

Author SHA1 Message Date
Petrik
3551a95e53 Use DidYouMean for ActionNotFound
If an action isn't found on a controller we can suggest similar actions:

```
The action 'indx' could not be found for SimpleController
Did you mean?  index
```
2020-05-18 15:41:26 +02:00
Ryuta Kamizono
98a1405f07 Dogfooding "active_support/core_ext/symbol/starts_ends_with"
Any missing thing would be found such like #39159.
2020-05-06 14:19:25 +09:00
Xavier Noria
5b28a0e972 Remove require_dependency usage in helper [Closes #37632]
Motivation is twofold:

  * We are gradually removing `require_dependency` from the framework.

  * Let `helper` work if `config.add_autoload_paths_to_load_path` is
    disabled.

Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2020-05-02 17:57:55 +02:00
Rafael Mendonça França
f1a2c021e3
Make _protected_ivars private
This method is only used internally and it being public it was being
retorned in the `action_methods` list.
2020-04-07 12:45:19 -04:00
Vitalii Khustochka
edcccf4990 Only compute :only and :except callback conditions once
Ref: https://github.com/rails/rails/issues/38679

`_normalize_callback_options` mutates the options hash, but
doesn't remove the `:only` and `:except` conditions.

So if you call `before_action` & al with the same option hash
you end up with multiple instance of identical `:if` / `:unless` procs
2020-04-06 11:51:30 +02:00
Vinicius Stock
9caaf26503
Use array subtraction to compute variables of interest in view_assigns 2020-03-19 15:59:46 -04:00
Vinicius Stock
f6bf17058e
Remove extra loop in view_assigns (#38766)
* Remove extra loop in view_assigns

* Use slice instead of range
2020-03-20 03:04:49 +09:00
Ryuta Kamizono
1ef8c60dfc Avoid extra string allocation in the methods generated by eval 2020-03-10 17:43:35 +09:00
Ryuta Kamizono
051e349041 Prefer faster str.start_with? over str.first ==
```ruby
str = "abc"

Benchmark.ips do |x|
  x.report("start_with?") { str.start_with?("a") }
  x.report("first ==")    { str.first == "a" }
end
```

```
Warming up --------------------------------------
         start_with?   282.381k i/100ms
            first ==   207.305k i/100ms
Calculating -------------------------------------
         start_with?     10.239M (± 2.2%) i/s -     51.393M in   5.022151s
            first ==      4.593M (± 4.5%) i/s -     23.011M in   5.021434s
```
2020-02-05 19:15:33 +09:00
Ryuta Kamizono
b803ed012c Make localize helper takes keyword arguments the same with I18n.localize 2020-02-05 18:49:44 +09:00
Ryuta Kamizono
6c02fee08f Make translate helper takes keyword arguments the same with I18n.translate 2020-02-05 18:04:27 +09:00
Ryuta Kamizono
a33dbb17b0 Follow up fa986ae0cac423bf1ebcb5caeccbecf00c990094 2020-02-05 14:31:11 +09:00
Xavier Noria
cb3b37b379 Deletes the private method add_template_helper
The method add_template_helper is private and used only in one place.
I guess its purpose was to remove the noise of module_eval at the cost
of an indirection.

However, Module#include is public since Ruby 2.1, and the indirection
is no longer justified for my taste. The loop in the caller is more
straightforward now.
2020-01-26 14:28:40 +01:00
Adam Hess
85f95b2f58 prevent helper_method from calling to_hash
`helper_method` was taking `**kwargs` on all definitions by default.
ruby will assume that this means you want keyword args and call
`to_hash` on what you pass if the object responds to `to_hash`. Instead
we should only take keyword args if the helper method defined intends
to pass keyword args.

This also fixes a warning when you pass a hash to your helper method,

```
warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
```

Also, this would be a good candidate for using `...`, but since `send`
requires the method as the first argument, we can't use it here.
2020-01-14 15:33:33 -08:00
Jared Fine
1ead658616 Switch to standardized argument name 2019-12-27 12:35:21 -05:00
Ryuta Kamizono
abf0465b09 Merge pull request #38051 from Shopify/actionpack-6-0-stable-ruby-2.7-warnings
Fix Ruby 2.7 warnings in Action Pack 6.0
2019-12-20 23:02:54 +09:00
Akira Matsuda
9977b63c47 I18n.translate takes keyword arguments 2019-09-09 01:13:38 +09:00
Akira Matsuda
8ebd6e5ccc No need to dup options hash where it's not modified 2019-08-19 00:09:08 +09:00
Akira Matsuda
5ae814d016 Reduce Array assignment by not giving a name for unused *args 2019-07-31 17:41:34 +09:00
st0012
5745a3c092 Add Vary: Accept header when rendering
Problem description (quoted from @rafaelfranca's excellent explanation in https://github.com/rails/jquery-ujs/issues/318#issuecomment-88129005):

> Let say that we requested /tasks/1 using Ajax, and the previous page has the same url. When we click the back button the browser tries to get the response from its cache and it gets the javascript response. With vary we "fix" this behavior because we are telling the browser that the url is the same but it is not from the same type what will skip the cache.

And there's a Rails issue discussing about this problem as well https://github.com/rails/rails/issues/25842

Also, according to [RFC 7231 7.1.4](https://tools.ietf.org/html/rfc7231#section-7.1.4)

>  An origin server SHOULD send a Vary header field when its algorithm
>  for selecting a representation varies based on aspects of the request
>  message other than the method and request target

we should add `Vary: Accept` header when determining content based on the `Accept` header.

Although adding such header by default could cause unnecessary cache invalidation. But this PR only adds the header if:
- The format param is not provided
- The request is a `xhr` request
- The request has accept headers and the headers are valid

So if the user
- sends request with explicit format, like `/users/1.json`
- or sends a normal request (non xhr)
- or doesn't specify accept headers

then the header won't be added.

See the discussion in https://github.com/rails/rails/issues/25842 and
https://github.com/rails/rails/pull/36213 for more details.
2019-07-26 13:52:06 +08:00
Ryuta Kamizono
c81af6ae72 Enable Layout/EmptyLinesAroundAccessModifier cop
We sometimes say "✂️ newline after `private`" in a code review (e.g.
https://github.com/rails/rails/pull/18546#discussion_r23188776,
https://github.com/rails/rails/pull/34832#discussion_r244847195).

Now `Layout/EmptyLinesAroundAccessModifier` cop have new enforced style
`EnforcedStyle: only_before` (https://github.com/rubocop-hq/rubocop/pull/7059).

That cop and enforced style will reduce the our code review cost.
2019-06-13 12:00:45 +09:00
John Hawthorn
4ab00cfac0 Use file/line from call to helper_module 2019-06-03 20:06:57 -07:00
John Hawthorn
17424a7de1 Give HelperMethods module a name 2019-06-03 18:59:51 -07:00
Nazar Matus
341b5176c2
AbstractController::Translation#t: dup options 2019-02-15 18:21:41 +02:00
bogdanvlviv
b8231433d6
Remove unused code
- Remove `fragment_cache_key` helper declaration.
  It was removed in e70d3df7c9b05c129b0fdcca57f66eca316c5cfc

- Remove `by_private_lifo`.
  It is unused since a7becf147afc85c354e5cfa519911a948d25fc4d
2019-01-30 14:29:17 +00:00
Rafael Mendonça França
e70d3df7c9
Remove deprecated fragment_cache_key helper in favor of combined_fragment_cache_key 2019-01-17 16:08:31 -05:00
yuuji.yaginuma
9422433e1a Don't use deprecated Module#parents 2018-10-05 09:58:29 +09:00
schneems
235e734e1e Revert "Merge pull request #33970 from rails/eager-url-helpers"
Until #34050 can be resolved

This reverts commit 7f870a5ba2aa9177aa4a0e03a9d027928ba60e49, reversing
changes made to 6556898884d636c59baae008e42783b8d3e16440.
2018-10-03 16:15:47 -05:00
Yasuo Honda
aa3dcabd87 Add Style/RedundantFreeze to remove redudant .freeze
Since Rails 6.0 will support Ruby 2.4.1 or higher
`# frozen_string_literal: true` magic comment is enough to make string object frozen.
This magic comment is enabled by `Style/FrozenStringLiteralComment` cop.

* Exclude these files not to auto correct false positive `Regexp#freeze`
 - 'actionpack/lib/action_dispatch/journey/router/utils.rb'
 - 'activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb'

It has been fixed by https://github.com/rubocop-hq/rubocop/pull/6333
Once the newer version of RuboCop released and available at Code Climate these exclude entries should be removed.

* Replace `String#freeze` with `String#-@` manually if explicit frozen string objects are required

 - 'actionpack/test/controller/test_case_test.rb'
 - 'activemodel/test/cases/type/string_test.rb'
 - 'activesupport/lib/active_support/core_ext/string/strip.rb'
 - 'activesupport/test/core_ext/string_ext_test.rb'
 - 'railties/test/generators/actions_test.rb'
2018-09-29 07:18:44 +00:00
Aaron Patterson
338c3c45fa
Allow helpers to be deferred until the routes have been finalized
ActiveStorage::BaseController subclasses ActionController::Base.
ActionController::Base has an "inherited" hook set that includes the
routing helpers to any subclass of AC::Base.  Since
ActiveStorage::BaseController is a subclass of AC::Base, it will get
routing helpers included automatically.  Unfortunately, when the
framework is eagerly loaded, ActiveStorage::BaseController is loaded
*before* the applications routes are loaded which means it attempts to
include an "in flight" module so it gets an exception.

This commit allows a class that's interested in being extended with
routing helpers register itself such that when the routes are finalized,
it will get the helpers included.  If the routes are already finalized,
then the helpers get included immediately.
2018-09-25 14:58:39 -07:00
schneems
e92adb3da6 Fewer allocations in caching/fragments.rb
Instead of using a splat on the head and tail we can mutate the array by flattening 1 level. We get further savings by not allocating another via `compact` but instead by using `compact!`
2018-08-29 09:49:24 -05:00
bogdanvlviv
4800a613c0
Remove extra execution of uniq! on action_methods
Execution of `to_set` below should remove duplicated elements.

Follow up #33693
2018-08-22 23:48:00 +03:00
schneems
4efb319141 Two fewer array allocations on action_methods
Instead of creating new arrays for `uniq` and `map` we can instead modify the array in place.
2018-08-22 11:17:50 -05:00
yuuji.yaginuma
f9dbc69c64 Show the ENV value correctly in the doc of combined_fragment_cache_key [ci skip]
It seems to need an escape for the showing `ENV`.
https://api.rubyonrails.org/classes/AbstractController/Caching/Fragments.html#method-i-combined_fragment_cache_key
2018-08-22 12:33:03 +09:00
Bart de Water
eb5fea40a4 Enable Start/EndWith and RegexpMatch cops
In cases where the MatchData object is not used, this provides a speed-up:
https://github.com/JuanitoFatas/fast-ruby/#stringmatch-vs-stringmatch-vs-stringstart_withstringend_with-code-start-code-end
2018-07-28 17:37:17 -04:00
Paul McMahon
7b9c19d94b Rails guides are now served over https
http links will be redirected to the https version, but still better to
just directly link to the https version.
2018-07-24 11:29:31 +09:00
Zachary Wasserman
9c6b3204d4 Add cancellation info to before filter docs
It is important for users to know that a render or redirect in a "before"
filter causes the action to be cancelled. This was addressed in the guide, but
not the API docs
(http://guides.rubyonrails.org/action_controller_overview.html#filters).

[ci skip]
2018-03-14 12:18:10 -07:00
Akira Matsuda
b0d0c9f40d [Action Pack] require => require_relative
This basically reverts e9fca7668b9eba82bcc832cb0061459703368397, d08da958b9ae17d4bbe4c9d7db497ece2450db5f,
d1fe1dcf8ab1c0210a37c2a78c1ee52cf199a66d, and 68eaf7b4d5f2bb56d939f71c5ece2d61cf6680a3
2017-10-21 22:48:28 +09:00
Ryuta Kamizono
a52ff1b084 Keep :api: plugin methods in the doc [ci skip]
`:api:` tag was removed in 5349f231 since RDoc doesn't support `:api:`
tag. But those methods are not private API, they are public API for
renderers. The renderers should be able to know that they can override
this method.
2017-10-20 05:47:34 +09:00
Ryuta Kamizono
2ae89f8b79 Make internal methods in AbstractController::Rendering to private 2017-10-02 06:56:57 +09:00
Ryuta Kamizono
5349f23108 Remove :api: tag that has leaked on the doc directly [ci skip]
Currently `:api:` tag has leaked on the doc directly since RDoc doesn't
support `:api:` tag directive.

http://api.rubyonrails.org/v5.1/classes/AbstractController/Rendering.html

So `:api: private` doesn't work as expected. We are using `:nodoc:` for
the purpose.

Related #13989.
2017-09-30 18:42:46 +09:00
Yoshiyuki Hirano
70756b134f Replace unnecessary link with typewriter text [ci skip] 2017-09-02 11:05:54 +09:00
Kir Shatrov
dfcc766163 Use frozen string literal in actionpack/ 2017-07-29 14:02:40 +03:00
Akira Matsuda
d08da958b9 [Abstract Controller] require => require_relative 2017-07-01 18:38:04 +09:00
fatkodima
2768cd1d74 Remove useless class checking for ActiveSupport::Callbackss result_lambda 2017-06-27 21:34:28 +03:00
Vipul A M
ff3c06f718
Allow translate default option to accept an array similar to i18n.t. Fixes #29441 2017-06-15 01:06:04 +05:30
David Heinemeier Hansson
1c275d812f Add option for class_attribute default (#29270)
* Allow a default value to be declared for class_attribute

* Convert to using class_attribute default rather than explicit setter

* Removed instance_accessor option by mistake

* False is a valid default value

* Documentation
2017-05-29 18:01:50 +02:00
Robin Dupret
0cbb130cf5 Merge pull request #29072 from dixpac/dixpac/add_documentation_for_validate_and_callback_order_of_execution
Improving docs for callbacks execution order [ci skip]
2017-05-21 21:34:47 +02:00
dixpac
4f39556577 Improving docs for callbacks execution order [ci skip]
When define callbacks latest definition on the same callback/method
overwrites previous ones.
2017-05-21 18:45:59 +02:00
Alex Kitchens
c01ea3e549 Merge pull request #29134 from joshaidan/document-action-name
Add documentation to accessors in AbstractController::Base
2017-05-19 08:32:19 -05:00
Brian Jones
73294bc96c Clarified description of formats [ci skip] 2017-05-19 01:48:38 -04:00
Brian Jones
f63a69e92a Added missing punctuation [ci skip] 2017-05-18 13:57:15 -04:00
David Heinemeier Hansson
75fa8dd309 Use recyclable cache keys (#29092) 2017-05-18 18:12:32 +02:00
Brian Jones
89e079f8fd Specify only the body of the response is returned [ci skip] 2017-05-18 11:46:20 -04:00
Brian Jones
73293053b5 Document accessors response_body, action_name, formats [ci skip] 2017-05-17 19:32:56 -04:00
Stan Lo
c61488b4ad Unfreeze interpolated string because it's useless. 2017-02-19 23:32:36 +08:00
Stan Lo
dde7134e07 Freeze fragment cache related instrument name.
ActionMailer::Base#instrument_name and
ActionController::Base#instrument_name will be frequently called once
caching is enabled. So it's better to freeze them instead of create new
string on every call.

Also, the instrument name in #instrument_fragment_cache will usually
be "write_fragment.action_controller" or
"read_fragment.action_controller". So freezing them might also gain some
performance improvement. We have done something like this in other places:
https://github.com/rails/rails/blob/master/actionview/lib/action_view/template.rb#L348
2017-02-07 00:41:02 +08:00
Jeremy Evans
7da8d76206
Change ActionView ERB Handler from Erubis to Erubi
Erubi offers the following advantages for Rails:

* Works with ruby's --enable-frozen-string-literal option
* Has 88% smaller memory footprint
* Does no freedom patching (Erubis adds a method to Kernel)
* Has simpler internals (1 file, <150 lines of code)
* Has an open development model (Erubis doesn't have a
  public source control repository or bug tracker)
* Is not dead (Erubis hasn't been updated since 2011)

Erubi is a simplified fork of Erubis that contains just the
parts that are generally needed (which includes the parts
that Rails uses).  The only intentional difference in
behavior is that it does not include support for <%=== tags
for debug output.  That could be added to the ActionView ERB
handler if it is desired.

The Erubis template handler remains in a deprecated state
so that code that accesses it directly does not break.  It
can be removed after Rails 5.1.
2017-01-25 01:41:27 -07:00
Jon Moss
feacb99003 Extract variant setter to process method
Provide an API interface similar to how format is handled in
Controllers. In situations where variants are not needed (ex: in
Action Mailer) the method will simply trigger a no-op, and will not
affect end users.
2017-01-02 19:05:09 -05:00
Akira Matsuda
bc4781583d Privatize unneededly protected methods in Action Pack 2016-12-24 18:54:48 +09:00
Andrew White
0ef5b6c163 Merge pull request #26905 from bogdanvlviv/docs
Add missing `+` around a some literals.
2016-11-13 14:09:30 +00:00
Rafael Mendonça França
fe1f4b2ad5
Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
Xavier Noria
7506f33906 removes requires already present in active_support/rails 2016-10-27 09:45:20 +02:00
bogdanvlviv
5faa9a235c Add missing + around a some literals.
Mainly around `nil`

[ci skip]
2016-10-27 00:27:47 +03:00
Rafael Mendonça França
d7be30e8ba
Remove deprecated methods related to controller filters
`skip_action_callback`, `skip_filter`, `before_filter`,
`prepend_before_filter`, `skip_before_filter`,
`append_before_filter`, `around_filter`
`prepend_around_filter`, `skip_around_filter`,
`append_around_filter`, `after_filter`,
`prepend_after_filter`, `skip_after_filter` and
`append_after_filter`.
2016-10-09 23:56:14 -03:00
Ryuta Kamizono
3464cd5c28 Fix broken comments indentation caused by rubocop auto-correct [ci skip]
All indentation was normalized by rubocop auto-correct at 80e66cc4d90bf8c15d1a5f6e3152e90147f00772.
But comments was still kept absolute position. This commit aligns
comments with method definitions for consistency.
2016-09-14 18:26:32 +09: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
a9dc45459a code gardening: removes redundant selfs
A few have been left for aesthetic reasons, but have made a pass
and removed most of them.

Note that if the method `foo` returns an array, `foo << 1`
is a regular push, nothing to do with assignments, so
no self required.
2016-08-08 01:12:38 +02:00
Stan Lo
ab2af4dfcb Modify LogSubscriber for single partial's cache message.
Implement naive partial caching mechanism.

Add test for LogSubscriber

Use ActionView::Base#log_payload to store log_subscriber's payload, so we can pass cache result into it.

Fixed tests

Remove useless settings

Check if #log_payload exists before calling it. Because other classes also includes CacheHelper but don't have is attribute

Use @log_payload_for_partial_reder instead of #log_payload to carry ActionView's payload.

Update test's hash syntax

Add configuration to enable/disable fragment caching logging

Remove unless test and add new test to ensure cache info won't effect next rendering's log

Move :enable_fragment_cache_logging config from ActionView to ActionPack

Apply new config to tests

Update actionview's changelog

Update configuration guide

Improve actionview's changelog

Refactor PartialRenderer#render and log tests

Mute subscriber's log instead of disabling instrumentation.

Fix typo, remove useless comment and use new hash syntax

Improve actionpack's log_subscriber test

Fix rebase mistake

Apply new config to all caching intstrument actions
2016-08-08 00:24:39 +08:00
Xavier Noria
80e66cc4d9 normalizes indentation and whitespace across the project 2016-08-06 20:16:27 +02:00
Xavier Noria
5b6eb1d58b modernizes hash syntax in actionpack 2016-08-06 19:35:13 +02:00
Xavier Noria
628e51ff10 applies new string literal convention in actionpack/lib
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 18:51:43 +02:00
Brandon Medenwald
f12c42fff2 render_to_string Regression Outside of Real Requests in Rails 5.0.0.rc1 (#25308)
* Restore the functionality of PR#14129, but do so with not nil to better indicate the purpose of the conditional

* Add a test when render_to_string called on ActionController::Base.new()
2016-06-09 09:36:07 -04:00
Jeff Kreeftmeijer
f650e03242 Use #performed? to terminate controller callbacks
Since 69009f, `ActionController::Metal::DataStreaming#send_file` doesn't
set `@_response_body` anymore.

`AbstractController::Callbacks` used `@_response_body` in its callback
terminator, so it failed to halt the callback cycle when using `#send_file`
from a `before_action`.

Instead, it now uses `#performed?` on `AbstractController::Base` and
`ActionController::Metal`, which checks `response.committed?`, besides
 checking if `@_response_body` is set, if possible.

Example application: https://gist.github.com/jeffkreeftmeijer/78ae4572f36b198e729724b0cf79ef8e
2016-06-03 16:04:12 +02:00
Rafael Mendonça França
e3b239cc1a
Revert "Make sure the cache is always populated"
This reverts commit 0ce7eae7418f1b9bb06b351c1f26d50c3674c0d0.

Tests were broken https://travis-ci.org/rails/rails/jobs/131850726#L520
2016-05-20 23:28:00 -03:00
Aaron Patterson
0ce7eae741
Make sure the cache is always populated
This way we don't have to make multiple calls on anonymous controllers
2016-05-20 18:30:34 -07:00
Rafael Mendonça França
cece50d3a6 Move protected instance variable to the right place
There were a lot of protected instance variables in
AbsctractController::Rendering that were related to Action Controller
and Action View.

Moving to ActionController::Base's protected instance list we make it
closer to where they are really defined.
2016-05-05 11:18:10 -05:00
Tom Kadwill
5646895b7f Actioncable and Actionpack documentation typos [ci skip] 2016-04-21 21:32:06 +01:00
Sean Griffin
12cce89c89 Break up a circular require between AP/AV
Right now referencing the constant `AbstractController::Rendering`
causes `ActionView::Base` to be loaded, and thus the load hooks for
action_view are run. If that load hook references any part of action
view that then references action controller (such as
`ActionView::TestCase`), the constant `AbstractController::Rendering`
will attempt to be autoloaded and blow up.

With this change, `ActionView::LoadPaths` no longer requires
`ActionView::Base` (which it had no reason to require). There was a
needed class from `AbstractController::Base` in the Rendering module,
which I've moved into its own file so we don't need to load
all of `AbstractController::Base` there.

This commit fixes
https://github.com/rails/rails-controller-testing/issues/21
2016-03-11 14:42:47 -07:00
Rafael França
cf1d45bd89 Merge pull request #24091 from mcfiredrill/fix-helper-method-docs
clarify that helper_method makes both methods available in the view [ci skip]
2016-03-07 00:00:22 -03:00
Tony Miller
05516a3156 clarify that helper_method makes both methods available in the view
It's probably obvious to most, but clarify that `:helper_method` will make both
of these methods available to the view.
2016-03-07 11:54:20 +09:00
Rafael Mendonça França
40fa818580 Move Caching module to Abstract Controller
Abstract Controller is the common component between Action Mailer and
Action Controller so if we need to share the caching component it need
to be there.
2016-02-23 21:11:15 -03:00
Aaron Patterson
00285e7cf7 fix permitted? conditional for render calls 2016-01-26 18:00:49 -08:00
Jon Moss
534b12afb5 Fix undefined error for ActionController::Parameters 2016-01-26 20:16:40 -05:00
Aaron Patterson
6dfab475ca Merge branch '5-0-beta-sec'
* 5-0-beta-sec:
  bumping version
  fix version update task to deal with .beta1.1
  Eliminate instance level writers for class accessors
  allow :file to be outside rails root, but anything else must be inside the rails view directory
  Don't short-circuit reject_if proc
  stop caching mime types globally
  use secure string comparisons for basic auth username / password
2016-01-25 11:25:11 -08:00
Aaron Patterson
b7758b40fc allow :file to be outside rails root, but anything else must be inside the rails view directory
CVE-2016-0752
2016-01-22 15:02:27 -08:00
Vijay Dev
b691d62be9 Merge branch 'master' of github.com:rails/docrails 2015-12-20 12:33:46 +00:00
yui-knk
21f4017fd9 Deprecate passing string to define callback. 2015-12-16 19:56:20 +09:00
Gaurav Sharma
762f7daf55 Add missing punctuation mark [ci skip] 2015-11-18 08:22:16 +05:30
Vijay Dev
153d7ca630 Merge branch 'master' of github.com:rails/docrails 2015-11-15 19:16:58 +00:00
Gaurav Sharma
899b6bbef3 adding missing . 2015-11-15 00:10:02 +05:30
Aaron Patterson
d5890bdf66 remove present? call; we do not need it 2015-11-02 15:20:13 -08:00
Aaron Patterson
8941831733 Revert "ActionController::Base#process() now only takes an action name"
This reverts commit 9f93a5efbba3e1cbf0bfa700a17ec8d1ef60d7c6.
2015-10-29 16:18:27 -07:00
Aaron Patterson
9f93a5efbb ActionController::Base#process() now only takes an action name
rather than an action name and *args.  The *args were not being used in regular
applications outside tests.  This causes a backwards compatibility
issue, but reduces array allocations for most users.
2015-10-29 15:40:18 -07:00
Gaurav Sharma
4ff9a824bf specify deprecated waring, follow the standard conventions
`skip_filter`, `skip_action_callback` may both are deprecated in Rails 5.1 so waring msg should be specific.
2015-10-28 13:09:18 +05:30
Jeremy Daer
565094a8b5 Use Mime[:foo] instead of Mime::Type[:FOO] for back compat
Rails 4.x and earlier didn't support `Mime::Type[:FOO]`, so libraries
that support multiple Rails versions would've had to feature-detect
whether to use `Mime::Type[:FOO]` or `Mime::FOO`.

`Mime[:foo]` has been around for ages to look up registered MIME types
by symbol / extension, though, so libraries and plugins can safely
switch to that without breaking backward- or forward-compatibility.

Note: `Mime::ALL` isn't a real MIME type and isn't registered for lookup
by type or extension, so it's not available as `Mime[:all]`. We use it
internally as a wildcard for `respond_to` negotiation. If you use this
internal constant, continue to reference it with `Mime::ALL`.

Ref. efc6dd550ee49e7e443f9d72785caa0f240def53
2015-10-06 11:29:30 -07:00
Aaron Patterson
69009f4473 move file sending to the response object
Just a slight refactor that delegates file sending to the response
object.  This gives us the advantage that if a webserver (in the future)
provides a response object that knows how to do accelerated file
serving, it can implement this method.
2015-10-05 16:50:50 -07:00
Aaron Patterson
e4ba720c17 stop calling deprecated methods
We should be asking the mime type method for the mime objects rather
than via const lookup
2015-09-21 12:04:12 -07:00
Aaron Patterson
cd8eb351fb push content_type assigment in to metal
everything above metal really doesn't care about setting the content
type, so lets rearrange these methods to be in metal.
2015-09-08 16:14:41 -07:00
Aaron Patterson
7056e2aa18 avoid useless string allocations
_set_content_type only does something when there is a request object,
otherwise the return value of _get_content_type is always ignored. This
commit moves everything to the module that has access to the request
object so we'll never to_s unless there is a reason
2015-09-08 16:14:41 -07:00