aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/abstract_controller/base.rb
Commit message (Collapse)AuthorAgeFilesLines
* Add missing `+` around a some literals.bogdanvlviv2016-10-271-4/+4
| | | | | | Mainly around `nil` [ci skip]
* applies new string literal convention in actionpack/libXavier Noria2016-08-061-7/+7
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Use `#performed?` to terminate controller callbacksJeff Kreeftmeijer2016-06-031-0/+7
| | | | | | | | | | | | | | | 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
* Revert "Make sure the cache is always populated"Rafael Mendonça França2016-05-201-5/+1
| | | | | | This reverts commit 0ce7eae7418f1b9bb06b351c1f26d50c3674c0d0. Tests were broken https://travis-ci.org/rails/rails/jobs/131850726#L520
* Make sure the cache is always populatedAaron Patterson2016-05-201-1/+5
| | | | This way we don't have to make multiple calls on anonymous controllers
* Actioncable and Actionpack documentation typos [ci skip]Tom Kadwill2016-04-211-1/+1
|
* Break up a circular require between AP/AVSean Griffin2016-03-111-3/+1
| | | | | | | | | | | | | | | | | | 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
* Add missing punctuation mark [ci skip]Gaurav Sharma2015-11-181-2/+2
|
* remove present? call; we do not need itAaron Patterson2015-11-021-1/+1
|
* Revert "ActionController::Base#process() now only takes an action name"Aaron Patterson2015-10-291-2/+2
| | | | This reverts commit 9f93a5efbba3e1cbf0bfa700a17ec8d1ef60d7c6.
* ActionController::Base#process() now only takes an action nameAaron Patterson2015-10-291-2/+2
| | | | | | 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.
* Remove not used requiresMarcin Olichwirowicz2015-09-011-1/+1
|
* Freeze string literals when not mutated.schneems2015-07-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I wrote a utility that helps find areas where you could optimize your program using a frozen string instead of a string literal, it's called [let_it_go](https://github.com/schneems/let_it_go). After going through the output and adding `.freeze` I was able to eliminate the creation of 1,114 string objects on EVERY request to [codetriage](codetriage.com). How does this impact execution? To look at memory: ```ruby require 'get_process_mem' mem = GetProcessMem.new GC.start GC.disable 1_114.times { " " } before = mem.mb after = mem.mb GC.enable puts "Diff: #{after - before} mb" ``` Creating 1,114 string objects results in `Diff: 0.03125 mb` of RAM allocated on every request. Or 1mb every 32 requests. To look at raw speed: ```ruby require 'benchmark/ips' number_of_objects_reduced = 1_114 Benchmark.ips do |x| x.report("freeze") { number_of_objects_reduced.times { " ".freeze } } x.report("no-freeze") { number_of_objects_reduced.times { " " } } end ``` We get the results ``` Calculating ------------------------------------- freeze 1.428k i/100ms no-freeze 609.000 i/100ms ------------------------------------------------- freeze 14.363k (± 8.5%) i/s - 71.400k no-freeze 6.084k (± 8.1%) i/s - 30.450k ``` Now we can do some maths: ```ruby ips = 6_226k # iterations / 1 second call_time_before = 1.0 / ips # seconds per iteration ips = 15_254 # iterations / 1 second call_time_after = 1.0 / ips # seconds per iteration diff = call_time_before - call_time_after number_of_objects_reduced * diff * 100 # => 0.4530373333993266 miliseconds saved per request ``` So we're shaving off 1 second of execution time for every 220 requests. Is this going to be an insane speed boost to any Rails app: nope. Should we merge it: yep. p.s. If you know of a method call that doesn't modify a string input such as [String#gsub](https://github.com/schneems/let_it_go/blob/b0e2da69f0cca87ab581022baa43291cdf48638c/lib/let_it_go/core_ext/string.rb#L37) please [give me a pull request to the appropriate file](https://github.com/schneems/let_it_go/blob/b0e2da69f0cca87ab581022baa43291cdf48638c/lib/let_it_go/core_ext/string.rb#L37), or open an issue in LetItGo so we can track and freeze more strings. Keep those strings Frozen ![](https://www.dropbox.com/s/z4dj9fdsv213r4v/let-it-go.gif?dl=1)
* [ci skip] Don't use TrueClass, FalseClass in docsclaudiob2015-07-021-6/+0
| | | | | | | | | This sort of documentation style comes from 2009, probably due to the merging of merb (see https://github.com/rails/rails/commit/38b608ecab2441cd0c4e75bc08bdf57fcf85dd71#diff-017d9bc9b1d2bdae199b938d72c15488R120). Rails follows Ruby's convention to define which values are "truthy" or "falsey", so there is no need to specify that the returned value must strictly be a TrueClass or FalseClass. /cc @fxn
* Remove mistaken end from controller_path doc [ci skip]Mehmet Emin İNAÇ2015-06-221-1/+1
|
* Remove ActionController::HideActions (closes #18336)brainopia2015-01-061-14/+2
|
* remove unneeded check since /_one_time_conditions/ is removedAditya Kapoor2015-01-051-2/+1
|
* Fix a few typos [ci skip]Robin Dupret2015-01-031-2/+2
|
* Better docs for AbstractControllerclaudiob2014-12-221-8/+12
| | | | | | Fixes internal links, adds examples and set fixed-width fonts. [ci skip]
* Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-291-1/+1
|
* Deprecate `*_path` methods in mailers@schneems and @sgrif2014-07-301-0/+8
| | | | | | | | | | | Email does not support relative links since there is no implicit host. Therefore all links inside of emails must be fully qualified URLs. All path helpers are now deprecated. When removed, the error will give early indication to developers to use `*_url` methods instead. Currently if a developer uses a `*_path` helper, their tests and `mail_view` will not catch the mistake. The only way to see the error is by sending emails in production. Preventing sending out emails with non-working path's is the desired end goal of this PR. Currently path helpers are mixed-in to controllers (the ActionMailer::Base acts as a controller). All `*_url` and `*_path` helpers are made available through the same module. This PR separates this behavior into two modules so we can extend the `*_path` methods to add a Deprecation to them. Once deprecated we can use this same area to raise a NoMethodError and add an informative message directing the developer to use `*_url` instead. The module with warnings is only mixed in when a controller returns false from the newly added `supports_relative_path?`. Paired @sgrif & @schneems
* Relpace `=~ Regexp.new str` with `.include? str` in AC::Base#_valid_action_name?Viktar Basharymau2014-06-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Because it is more natural way to test substring inclusion. Also, in this particular case it is much faster. In general, using `Regexp.new str` for such kind of things is dangerous. The string must be escaped, unless you know what you're doing. Example: Regexp.new "\\" # HELLO WINDOWS # RegexpError: too short escape sequence: /\/ The right way to do this is escape the string Regexp.new Regexp.escape "\\" # => /\\/ Here is the benchmark showing how faster `include?` call is. ``` require 'benchmark/ips' Benchmark.ips do |x| x.report('include?') { !"index".to_s.include? File::SEPARATOR } x.report(' !~ ') { "index" !~ Regexp.new(File::SEPARATOR) } end __END__ Calculating ------------------------------------- include? 75754 i/100ms !~ 21089 i/100ms ------------------------------------------------- include? 3172882.3 (±4.5%) i/s - 15832586 in 5.000659s !~ 322918.8 (±8.6%) i/s - 1602764 in 4.999509s ``` Extra `.to_s` call is needed to handle the case when `action_name` is `nil`. If it is omitted, some tests fail.
* Remove duplicated to_s method call.Guo Xiang Tan2014-05-251-1/+1
|
* docs, make `ActionNotFound` public API. [ci skip]Yves Senn2014-05-111-1/+2
| | | | | | | | | This is a follow up to #15058. This exception is regularly raised during development. This means it will enter the user realm. We should provide an API page to show that this exception is public API. /cc @schneems
* adding complete message in documentation [ci skip]Gaurav Sharma2014-05-111-3/+4
|
* Only accept actions without File::SEPARATOR in the name.Rafael Mendonça França2014-05-061-3/+25
| | | | | | | | | This will avoid directory traversal in implicit render. Fixes: CVE-2014-0130 Conflicts: actionpack/lib/abstract_controller/base.rb
* Get rid of extra local var that does not add to the logicCarlos Antonio da Silva2014-05-051-2/+2
| | | | There are too many "action name" variables around the process method.
* Capitalize the first letter of sentenceTatsuro Baba2013-03-181-1/+1
|
* fix uninitialized ivar warningsAaron Patterson2012-10-251-0/+10
|
* remove 'then' from conditional statementNihad Abbasov2012-10-141-2/+4
|
* copy edit[ci skip]Vijay Dev2012-05-231-1/+1
|
* Update documentation for AbstractController::BaseHenrik Hodne2012-05-201-3/+11
|
* avoid empty api pagesVijay Dev2012-04-081-2/+5
|
* AbstractController.action_methods should return a SetSantiago Pastorino2012-03-101-2/+3
|
* Fix AbstractController#controller_path docAlexey Vakhov2012-02-191-1/+1
|
* Fix AbstractController::Base#hidden_actions commentAlexey Vakhov2012-02-181-2/+2
|
* Remove extra white spaces on ActionPack docs.Sebastian Martinez2011-05-231-1/+1
|
* better styling on #available_action? docsSebastian Martinez2011-05-061-2/+2
|
* Revert to old semantics, use available_action? instead of action_method?.José Valim2011-05-061-13/+25
|
* Implicit actions named not_implemented can be renderedSantiago Pastorino2011-04-021-0/+2
|
* Make action_method? public and change implicit rendering to override it instead.José Valim2011-03-301-15/+18
|
* Rewording existing commentNeeraj Singh2010-11-301-4/+3
|
* Fix a few bugs when trying to use Head standalonewycats2010-10-101-0/+1
|
* oops, missed a uniqAaron Patterson2010-09-291-1/+1
|
* dry up action_methodsAaron Patterson2010-09-291-4/+4
|
* fixed capitalizationJoost Baaij2010-08-251-8/+8
|
* change rdoc to conform to api guidelinesJoost Baaij2010-08-251-11/+13
|
* Deletes trailing whitespaces (over text files only find * -type f -exec sed ↵Santiago Pastorino2010-08-141-1/+1
| | | | 's/[ \t]*$//' -i {} \;)
* Reload action_methods in AbstractController after defining new method.Piotr Sarnacki2010-08-041-0/+12
| | | | Signed-off-by: José Valim <jose.valim@gmail.com>
* ActiveRecord and ActionPack now use the new descendants implementation.José Valim2010-06-191-11/+2
|