aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/abstract_controller/helpers.rb
Commit message (Collapse)AuthorAgeFilesLines
* Enable Start/EndWith and RegexpMatch copsBart de Water2018-07-281-1/+1
| | | | | 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
* Use frozen string literal in actionpack/Kir Shatrov2017-07-291-0/+2
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* Add option for class_attribute default (#29270)David Heinemeier Hansson2017-05-291-5/+2
| | | | | | | | | | | | * 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
* Fix broken comments indentation caused by rubocop auto-correct [ci skip]Ryuta Kamizono2016-09-141-6/+6
| | | | | | 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.
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-12/+12
|
* applies new string literal convention in actionpack/libXavier Noria2016-08-061-2/+2
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* clarify that helper_method makes both methods available in the viewTony Miller2016-03-071-1/+2
| | | | | It's probably obvious to most, but clarify that `:helper_method` will make both of these methods available to the view.
* 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)
* Merge pull request #8740 from amatsuda/missing_source_fileRafael Mendonça França2015-01-021-1/+1
|\ | | | | | | | | | | | | replace use of MissingSourceFile with LoadError Conflicts: activesupport/test/core_ext/load_error_test.rb
| * replace use of MissingSourceFile with LoadErrorAkira Matsuda2013-01-041-1/+1
| |
* | give a better error message for misspelled helpersXavier Noria2014-10-251-1/+11
| | | | | | | | | | | | See comment in this patch for the rationale. References #16468
* | remove deprecated `MissingHelperError` proxy.Yves Senn2014-08-141-3/+0
| | | | | | | | The error was moved outside of the `ClassMethods` module.
* | move `MissingHelperError` out of the `ClassMethods` module.Yves Senn2013-07-121-15/+18
| |
* | Show real LoadError on helpers requirePiotr Niełacny2013-07-101-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When helper try to require missing file rails will throw exception about missing helper. # app/helpers/my_helper.rb require 'missing' module MyHelper end And when we try do load helper class ApplicationController helper :my end Rails will throw exception. This is wrong because there is a helper file. Missing helper file helpers/my_helper.rb Now when helper try to require non-existed file rails will throw proper exception. No such file to load -- missing
* | Prefer find_by over dynamic finders in rdocSam Ruby2013-04-021-1/+1
| |
* | Remove :all from *args options in AbstractController.helperBryan Ricker2013-03-161-1/+1
| |
* | Revert "Merge pull request #8989 from robertomiranda/use-rails-4-find-by"Guillermo Iguaran2013-01-181-1/+1
| | | | | | | | | | This reverts commit 637a7d9d357a0f3f725b0548282ca8c5e7d4af4a, reversing changes made to 5937bd02dee112646469848d7fe8a8bfcef5b4c1.
* | User Rails 4 find_byrobertomiranda2013-01-181-1/+1
|/
* Revert "Fix incorrect adjustment 4c41e87e3ae548c44810b66437b2f0f6e73b2106"Vijay Dev2012-12-211-1/+1
| | | | | | | | This reverts commit e1f8ec59f2cc83f052b15233147aa2d6d8114a4d. Reason: seems bad styling [ci skip]
* Fix incorrect adjustment 4c41e87e3ae548c44810b66437b2f0f6e73b2106kei2012-12-201-1/+1
|
* Fix documentation stylekei2012-12-201-1/+1
|
* Refactor helpers code in Action Pack a bitCarlos Antonio da Silva2012-12-131-1/+1
| | | | | | | | * Avoid calling class_eval when not needed * Remove helpers_path attr accessor, it's defined as a class attribute a few lines later * Avoid creating extra arrays when finding helpers, use flat_map and sort! * Remove not required refer variable when redirecting :back
* Cleans and removes useless 'Examples' tag [ci skip]Alvaro Pereyra2012-12-011-2/+1
|
* Fixed indendationAyrton De Craene2012-08-291-3/+3
|
* i suck, fixing error messageAaron Patterson2012-06-141-1/+1
|
* Wrap up missing helper exceptionsAaron Patterson2012-06-141-2/+10
| | | | | | | The `path` method on missing helper errors is inconsistent with the implementation on LoadError in Ruby 2.0. Wrap up the missing helper exceptions so that the inconsistent behavior is mirrored in Ruby 2.0 (until we can figure out *why* it's inconsistent).
* using hax to fix tests on Ruby 2.0Aaron Patterson2012-06-131-1/+6
|
* Add annotaion for class_eval in AbstractController#helper_method [ci skip]Edward Tsech2012-05-081-3/+3
|
* Remove extra white spaces on ActionPack docs.Sebastian Martinez2011-05-231-1/+1
|
* Move prefixes to view paths as they are now a lookup context dependency.José Valim2011-05-041-2/+0
|
* Make ActionController::Base.modules_for_helpers and ↵Piotr Sarnacki2011-04-251-11/+11
| | | | ActionController::Base.all_helpers_from_path public methods
* Ensure that inherited helper_methods are available after calling ↵Jesse Storimer2010-08-281-1/+11
| | | | | | clear_helpers [#5348 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* Add clear_helpers as a way to clean up all helpers added to this controller, ↵José Valim2010-08-261-0/+7
| | | | maintaing just the helper with the same name as the controller.
* change rdoc to conform to api guidelinesJoost Baaij2010-08-251-6/+6
|
* Clean up the config object in ActionPack. Create config_accessor which just ↵José Valim2010-04-221-1/+0
| | | | delegates to the config object, reducing the number of deprecations and add specific tests.
* Each controller class has it's own view context subclass. This removes the ↵Carlhuda2010-03-181-9/+1
| | | | need for ActionView::Base.for_controller
* Fix controller_path returnsing an empty string in Ruby 1.8.7 [#4036 ↵José Valim2010-02-261-3/+0
| | | | status:resolved]
* Update AP to start locking down a public API. This work is parallel to some ↵Yehuda Katz2010-02-161-2/+2
| | | | docs I'm working on.
* name.blank? -> anonymous?Xavier Noria2010-02-141-1/+2
| | | | Signed-off-by: Yehuda Katz <yehudakatz@YK.local>
* Convert to class_attributeJeremy Kemper2010-02-011-4/+6
|
* Fix some backward incompatible behavior on AM.José Valim2010-01-301-1/+11
|
* Rename the RenderingController module to just plain RenderingDavid Heinemeier Hansson2009-12-201-1/+1
|
* Remove ActionMailer helpers and rely on AbstractController one.José Valim2009-11-011-11/+70
|
* Experimental: Improve performance of ActionView by preventing method cache ↵Yehuda Katz2009-08-091-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | flushing due to runtime Kernel#extend: * The helper module adds a new _helper_serial property onto AbstractController subclasses * When #helper is used to add helpers to a class, the serial number is updated * An ActionView subclass is created and cached based on this serial number. * That subclass includes the helper module from the controller * Subsequent requests using the same controller with the same serial will result in reusing that subclass, rather than being forced to take an action (like include or extend) that will result in a global method cache flush on MRI and a flush of the entire AV class' cache on JRuby. * For now, this optimization is not applied to the RJS helpers, which results in a global method cache flush in MRI and a flush of the JavaScriptGenerator class in JRuby only when using RJS. * Since the effects are limited to using RJS, and would only affect JavaScriptGenerator in JRuby (as opposed to the entire view object), it seems worthwhile to apply this now. * This resulted in a significant performance improvement. I will have benchmarks in the next day or two that show the performance impact of the last several commits. * There is a small chance this could break existing code (although I'm not sure how). If that happens, please report it immediately.
* Renamed presenter to renderer, added some documentation and defined its API.José Valim2009-08-071-1/+1
|
* Move AbstractController to a top-level componentYehuda Katz2009-08-061-0/+82