Commit Graph

526 Commits

Author SHA1 Message Date
Marcin Olichwirowicz
b69699afda Remove not used requires 2015-09-01 20:36:47 +02:00
akihiro17
2de60a926b Set the content-type to text/html if the options[:html] is true
In this commit, we set the content-type to `text/html` in AbstractController if the `options[:html]` is true so that we don't include ActionView::Rendering into ActionController::Metal to set it properly.

I removed the if `options[:plain]` statement because `AbstractController#rendered_format` returns `Mime::TEXT` by default.
2015-08-29 01:02:43 +09:00
Aaron Patterson
e6425f6eca Remove useless conditional
If the response method is defined, then calling `response` will return a
response.
2015-08-26 16:34:07 -07:00
Aaron Patterson
446b6855dc remove useless code
If AV::Rendering is mixed in, then `rendered_format` will be calculated
based on the current `lookup_context`, but calling `_process_format`
will set the `rendered_format` back on to the same lookup context where
we got the information in the first place!

Instead of getting information from an object, then setting the same
information back on to that object, lets just do nothing instead!
2015-08-26 16:17:29 -07:00
Aaron Patterson
3b8395a882 only call self.content_type= when there is a response
Apparently the AbstractController (whatever "abstract" means) is
expected to work without a request and response.
2015-08-26 15:31:23 -07:00
Aaron Patterson
2ceb16e539 Pull plain content type handling up to render
`render` is the only possible source for the `plain` option.  Pulling
the conditional up to the `render` method removes far away conditionals
2015-08-26 14:04:04 -07:00
Aaron Patterson
fa09bf44db stop passing the options hash to _process_format
We don't need to pass the full hash just to pull one value out.  It's
better to just pass the value that the method needs to know about so
that we can abstract it away from "options"
2015-08-26 13:51:28 -07:00
Marcin Olichwirowicz
174b9a3097 Initialize symbols instead of mapping to_sym on the set of strings 2015-08-15 17:45:13 +02:00
schneems
5bb1d4d288 Freeze string literals when not mutated.
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](b0e2da69f0/lib/let_it_go/core_ext/string.rb (L37)) please [give me a pull request to the appropriate file](b0e2da69f0/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)
2015-07-19 17:45:10 -05:00
claudiob
352c8473ef [ci skip] Don't use TrueClass, FalseClass in docs
This sort of documentation style comes from 2009, probably due to
the merging of merb (see 38b608ecab (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
2015-07-02 08:08:46 -07:00
Mehmet Emin İNAÇ
b835c72bc9 Remove mistaken end from controller_path doc [ci skip] 2015-06-22 19:36:01 +03:00
Iain Beeston
d2876141d0 Raise ArgumentError if an unrecognised callback is skipped
At present, if you skip a callback that hasn't been defined,
activesupport callbacks silently does nothing. However, it's easy to
mistype the name of a callback and mistakenly think that it's being
skipped, when it is not.

This problem even exists in the current test suite.
CallbacksTest::SkipCallbacksTest#test_skip_person attempts to skip
callbacks that were never set up.

This PR changes `skip_callback` to raise an `ArgumentError` if the
specified callback cannot be found.
2015-04-03 09:37:19 +01:00
Vipul A M
cdaab2c479 Removed non-standard and unused require 'active_support/deprecation' from parts out of active_support. 2015-02-27 23:20:09 +05:30
yuuji.yaginuma
0eec7d2c96 fix NameError in skip_filter. callback doesn't exist. 2015-02-27 09:03:31 +09:00
Iain Beeston
3fbc632843 Deprecate AbstractController::Callbacks#skip_action_callback
As part of #19029, in future `skip_before_action`, `skip_after_action` and
`skip_around_action` will raise an ArgumentError if the specified
callback does not exist. `skip_action_callback` calls all three of these
methods and will almost certainly result in an ArgumentError. If anyone
wants to remove all three callbacks then they can still call the three
individual methods. Therefore let's deprecate `skip_action_callback` now
and remove it when #19029 is merged.
2015-02-24 08:17:24 +00:00
Rafael Mendonça França
76f6524538 Merge pull request #11790 from printercu/patch-3
ActionController#translate supports symbols
2015-02-12 15:39:17 -02:00
robertomiranda
ce8efcf296 Use public Module#include, in favor of https://bugs.ruby-lang.org/issues/8846
ref: https://github.com/rails/rails/pull/18763#issuecomment-72349769
2015-01-31 23:12:41 -05:00
Yves Senn
5170c11c97 fix typo in _filter deprecation message. [ci skip] 2015-01-30 14:01:58 +01:00
Abdelkader Boudih
7644a99d90 Deprecate all *_filter callbacks in favor of *_action callbacks 2015-01-08 20:52:36 +00:00
Rafael Mendonça França
b8e83ce1c5 Merge pull request #18404 from claudiob/rebase-14549
Add test case and documentation for skip_before_filter.
2015-01-08 18:08:02 -02:00
claudiob
9a25603d0a Add test/doc for :if/:except in skip_before_action
The new test/docs further explain the conflicts that can happen when
mixing `:if`/`:unless` options with `:only`/`:except` options in
`skip_before_action`.

The gist is that "positive" filters always have priority over negative
ones.

The previous commit already showed that `:only` has priority over `:if`.

This commit shows that `:if` has priority over `:except`.

For instance, the following snippets are equivalent:

```ruby
skip_before_action :some_callback, if: -> { condition }, except: action
```

```ruby
skip_before_action :some_callback, if: -> { condition }
```
2015-01-08 09:30:31 -08:00
Lauro Caetano
ae9f803c5d Add test case and documentation for skip_before_filter.
Test case for using skip_before_filter with the options :only and :if
both present. In this case, the :if option will be ignored and :only
will be executed.

Closes #14549 (the commit was cherry-picked from there).
2015-01-08 09:13:45 -08:00
brainopia
08d3f0e3b3 Remove ActionController::HideActions (closes #18336) 2015-01-06 23:40:45 +03:00
Aditya Kapoor
21dfe89ac7 remove unneeded check since /_one_time_conditions/ is removed 2015-01-05 16:52:19 +05:30
Rafael Mendonça França
4591b0fc04 Merge pull request #17227 from claudiob/explicitly-abort-callbacks
Introduce explicit way of halting callback chains by throwing :abort. Deprecate current implicit behavior of halting callback chains by returning `false` in apps ported to Rails 5.0. Completely remove that behavior in brand new Rails 5.0 apps.

Conflicts:
	railties/CHANGELOG.md
2015-01-03 17:22:20 -03:00
Robin Dupret
9b9ec0ded4 Fix a few typos [ci skip] 2015-01-03 16:36:33 +01:00
Vijay Dev
4b9dba99d6 Merge branch 'master' of github.com:rails/docrails 2015-01-03 14:58:17 +00:00
claudiob
2386daabe7 Throw :abort halts default CallbackChains
This commit changes arguments and default value of CallbackChain's :terminator
option.

After this commit, Chains of callbacks defined **without** an explicit
`:terminator` option will be halted as soon as a `before_` callback throws
`:abort`.

Chains of callbacks defined **with** a `:terminator` option will maintain their
existing behavior of halting as soon as a `before_` callback matches the
terminator's expectation. For instance, ActiveModel's callbacks will still
halt the chain when a `before_` callback returns `false`.
2015-01-02 15:31:55 -08:00
Rafael Mendonça França
48deeab90a Merge pull request #8740 from amatsuda/missing_source_file
replace use of MissingSourceFile with LoadError

Conflicts:
	activesupport/test/core_ext/load_error_test.rb
2015-01-02 19:19:59 -03:00
claudiob
bea61d6670 Better docs for AbstractController
Fixes internal links, adds examples and set fixed-width fonts.

[ci skip]
2014-12-22 03:53:48 +01:00
Erik Michaels-Ober
d1374f99bf Pass symbol as an argument instead of a block 2014-11-29 11:53:24 +01:00
Xavier Noria
8d7cf75684 give a better error message for misspelled helpers
See comment in this patch for the rationale.

References #16468
2014-10-25 14:06:33 +02:00
Yves Senn
a1ddde15ae remove deprecated MissingHelperError proxy.
The error was moved outside of the `ClassMethods` module.
2014-08-14 09:37:21 +02:00
@schneems and @sgrif
2bbcca004c Deprecate *_path methods in mailers
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
2014-07-30 12:01:45 -05:00
Viktar Basharymau
453cd7b617 Relpace =~ Regexp.new str with .include? str in AC::Base#_valid_action_name?
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.
2014-06-19 18:39:58 +03:00
Rafael Mendonça França
489a8f2a44 Partially revert deprecation of *_filter
We are going to deprecate only on Rails 5 to make easier plugin
maintainers support different Rails versions. Right now we are only
discouraging their usage.

This reverts commit 6c5f43bab8206747a8591435b2aa0ff7051ad3de.

Conflicts:
	actionpack/CHANGELOG.md
2014-06-03 19:53:28 -03:00
Rafael Mendonça França
6c5f43bab8 Deprecate all *_filter callbacks in favor of *_action callbacks
This is the continuation of the work started at
9d62e04838f01f5589fa50b0baa480d60c815e2c
2014-05-27 19:10:14 -03:00
Guo Xiang Tan
86396f8c30 Remove duplicated to_s method call. 2014-05-25 19:07:57 -07:00
Aida
812b4e88b7 fixed a typo [ci skip] 2014-05-17 00:29:09 +09:00
Yves Senn
65b9abf561 docs, make ActionNotFound public API. [ci skip]
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
2014-05-11 15:22:26 +02:00
Gaurav Sharma
bc9b3313e4 adding complete message in documentation [ci skip] 2014-05-11 18:11:23 +05:30
Rafael Mendonça França
bdcd5f94b2 Only accept actions without File::SEPARATOR in the name.
This will avoid directory traversal in implicit render.

Fixes: CVE-2014-0130

Conflicts:
	actionpack/lib/abstract_controller/base.rb
2014-05-06 13:36:58 -03:00
Carlos Antonio da Silva
9381d823a5 Get rid of extra local var that does not add to the logic
There are too many "action name" variables around the process method.
2014-05-05 08:14:07 -03:00
kirill
2717f004fa replace class_eval by define_method in abstract_controller/callbacks 2014-04-20 22:08:17 +04:00
Joan Karadimov
f6d9b68997 Check if the request variable isn't nil when calling render_to_string
closes #14125
2014-02-20 20:53:47 +02:00
Prem Sichanugrist
103e18c87d Introduce render :body for render raw content
This is an option for sending a raw content back to browser. Note that
this rendering option will unset the default content type and does not
include "Content-Type" header back in the response.

You should only use this option if you are expecting the "Content-Type"
header to not be set. More information on "Content-Type" header can be
found on RFC 2616, section 7.2.1.

Please see #12374 for more detail.
2014-02-18 12:08:36 -05:00
Philipe Fatio
47860b62b3 Require action_view to fix missing constant
Previously, requiring action_view/view_paths did cause an uninitialized
constant error for ENCODING_FLAG, which is defined in action_view.
2014-02-07 17:48:18 +01:00
Carlos Antonio da Silva
618d5317d3 Move the null mime type to request.format
TLDR: always return an object that responds to the query methods from
request.format, and do not touch Mime::Type[] lookup to avoid bugs.

---

Long version:

The initial issue was about being able to do checks like
request.format.html? for request with an unknown format, where
request.format would be nil.

This is where the issue came from at first in #7837 and #8085
(merged in cba05887dc3b56a46a9fe2779b6b228880b49622), but the
implementation went down the path of adding this to the mime type
lookup logic.

This unfortunately introduced subtle bugs, for instance in the merged
commit a test related to send_file had to be changed to accomodate the
introduction of the NullType.

Later another bug was found in #13064, related to the content-type being
shown as #<Mime::NullType:...> for templates with localized extensions
but no format included. This one was fixed in #13133, merged in
43962d6ec50f918c9970bd3cd4b6ee5c7f7426ed.

Besides that, custom handlers were not receiving the proper template
formats anymore when passing through the rendering process, because of
the NullType addition. That was found while migrating an application
from 3.2 to 4.0 that uses the Markerb gem (a custom handler that
generates both text and html emails from a markdown template).

---

This changes the implementation moving away from returning this null
object from the mime lookup, and still fixes the initial issue where
request.format.zomg? would raise an exception for unknown formats due to
request.format being nil.
2013-12-23 16:16:49 -02:00
Vijay Dev
a3b1105ada Merge branch 'master' of github.com:lifo/docrails 2013-12-20 00:10:30 +05:30
Łukasz Strzałkowski
d99dd0af03 Require action_view explicitly in AC::Base 2013-12-08 13:03:41 +01:00
Jeremy Kemper
5086c8c211 Merge pull request #13189 from strzalek/retain-ap-av-dep
Retain ActionPack dependency on ActionView. Fixes #12979.
2013-12-05 07:25:17 -08:00
Łukasz Strzałkowski
d8888b94b3 Retain ActionPack dependency on ActionView 2013-12-05 01:02:46 +01:00
Carlos Antonio da Silva
3b40a5d83d Improve a couple exception messages related to variants and mime types
Avoid one-liner conditionals when they are too big. Avoid concatenating
strings to build error messages. Improve messages a bit.
2013-12-03 22:23:12 -02:00
Łukasz Strzałkowski
2d3a6a0cb8 Action Pack Variants
By default, variants in the templates will be picked up if a variant is set
and there's a match. The format will be:

  app/views/projects/show.html.erb
  app/views/projects/show.html+tablet.erb
  app/views/projects/show.html+phone.erb

If request.variant = :tablet is set, we'll automatically be rendering the
html+tablet template.

In the controller, we can also tailer to the variants with this syntax:

  class ProjectsController < ActionController::Base
    def show
      respond_to do |format|
        format.html do |html|
          @stars = @project.stars

          html.tablet { @notifications = @project.notifications }
          html.phone  { @chat_heads    = @project.chat_heads }
        end

        format.js
        format.atom
      end
    end
  end

The variant itself is nil by default, but can be set in before filters, like
so:

  class ApplicationController < ActionController::Base
    before_action do
      if request.user_agent =~ /iPad/
        request.variant = :tablet
      end
    end
  end

This is modeled loosely on custom mime types, but it's specifically not
intended to be used together. If you're going to make a custom mime type,
you don't need a variant. Variants are for variations on a single mime
types.
2013-12-04 00:13:16 +01:00
Lauro Caetano
b1b9a0aeca Typos. return -> returns. [ci skip] 2013-12-03 13:31:36 -02:00
Aaron Patterson
267e5c84f9 calculate the ivars to remove in advance as a set and cache them in a
constant.

`view_assigns` can use the precalculated sets and remove instance
variables without allocating any extra arrays
2013-11-06 14:21:40 -08:00
Aaron Patterson
c8b566d54d use a set and reject to avoid array allocations 2013-11-06 14:11:37 -08:00
Aaron Patterson
779cd6ec61 each_with_object on the view_assigns hash 2013-11-06 13:54:15 -08:00
Aaron Patterson
9a4adb4b05 use slice to avoid range allocation 2013-11-06 13:53:52 -08:00
Aaron Patterson
697acc4025 these variables are also private 2013-11-06 13:37:24 -08:00
Aaron Patterson
32e94a488f instance_variables returns symbols, so we should use symbols in our list 2013-11-06 13:24:00 -08:00
Max Melentiev
fde7344542 ActionController#translate also lookups shortcut without action name 2013-10-22 18:17:05 +04:00
printercu
40a8130bc5 ActionController#translate supports symbols
Made it similar to views helper.
2013-09-25 16:23:28 +04:00
Santiago Pastorino
a46fa8df06 Make AC standalone rendering work 2013-09-10 11:01:12 -03:00
José Valim
1385ae138d Remove BasicRendering tests 2013-09-09 16:10:41 -03:00
José Valim
67336ce199 Remove remaining coupling with AV in MimeResponds 2013-09-09 12:33:53 -03:00
José Valim
a41669563b Remove BasicRendering and remove template functionality from AbsC::Rendering 2013-09-09 12:33:53 -03:00
Łukasz Strzałkowski
eddf367b89 Move BasicRendering to AbstractController 2013-09-03 15:03:56 +02:00
Łukasz Strzałkowski
d35cf4b6a0 Make Mime::TEXT default format in AbstractController 2013-09-03 14:58:46 +02:00
Łukasz Strzałkowski
aea02eb430 Move skeleton methods from AV to AbsC
The methods:

 * #render_to_body
 * #render_to_string
 * #_normalize_render

Haven't had anything specyfic to ActionView. This was common code which should belong to AbstractController
2013-09-03 14:57:37 +02:00
Łukasz Strzałkowski
544d0fad3d Return to using protected_instance_variables in AV 2013-09-02 23:18:02 +02:00
Łukasz Strzałkowski
40fcb9e822 Revert "Port all remaining self.protected_instance_variables to class methods"
This reverts commit 7de994fa215e9f4c2856d85034bc4dd7b65d0c01.
2013-09-02 23:18:02 +02:00
Łukasz Strzałkowski
7de994fa21 Port all remaining self.protected_instance_variables to class methods 2013-08-29 12:13:45 +02:00
Łukasz Strzałkowski
7d810049fe Add #rendered_format method to controllers 2013-08-25 11:39:13 +02:00
Łukasz Strzałkowski
1656f58f07 Improve AV::Rendering docs 2013-08-25 11:39:11 +02:00
Łukasz Strzałkowski
d6363aa180 Code formatting & typo fixes 2013-08-25 11:39:09 +02:00
Łukasz Strzałkowski
b9b48c7806 Remove abstract_controller load hooks 2013-08-25 11:39:09 +02:00
Łukasz Strzałkowski
49608f7b81 Move protected_instance_variables & view_assigns to AbstractController 2013-08-25 11:39:09 +02:00
Łukasz Strzałkowski
8e3413d410 Create AbstractController::Rendering interface
This interface should be use when implementing renderers.
2013-08-25 11:39:09 +02:00
Łukasz Strzałkowski
c90971644a Revert "Rename abstract_controller/rendering. to errors.rb"
This reverts commit 6fe91ec5008838338e54ab8570f7c95ee0cdd8e8.
2013-08-25 11:39:08 +02:00
Łukasz Strzałkowski
cad8a20187 Rename abstract_controller/rendering. to errors.rb
Since all rendering stuff was extracted to AV, the only thing that left was single class with error so file name wasn't relevant anymore
2013-08-25 11:39:08 +02:00
Łukasz Strzałkowski
766fa97b45 Hook up AV::Rendering on AV intialization 2013-08-25 11:39:08 +02:00
Łukasz Strzałkowski
5759531a95 Move rendering from AP to AV 2013-08-25 11:39:07 +02:00
Łukasz Strzałkowski
1b446d06dd Move view_paths from AP to AV 2013-08-25 11:39:07 +02:00
Nicholas Jakobsen
55cbb85fb7 Execute conditional procs on controller filters only for current action.
:only and :except options for controller filters are now added before
:if and :unless. This prevents running :if and :unless procs when not
on the specified. Closes #11786.
2013-08-10 09:13:20 -07:00
Yves Senn
5bee14f3a4 move MissingHelperError out of the ClassMethods module. 2013-07-12 15:34:29 +02:00
Piotr Niełacny
e0438b1c07 Show real LoadError on helpers require
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
2013-07-10 11:26:43 +02:00
Neeraj Singh
70568b4bbd use extract_options! 2013-07-02 22:46:31 +05:30
Aaron Patterson
ba55276434 deprecating string based terminators 2013-05-14 16:03:09 -07:00
printercu
14c196e5a3 Avoid leak into controller's action_methods 2013-04-18 20:03:31 +04:00
Sam Ruby
04cda1848c Prefer find_by over dynamic finders in rdoc 2013-04-02 15:09:15 -04:00
Carlos Antonio da Silva
0c5552a3dd Fix typos in AP: "overriden" => "overridden" 2013-03-30 15:17:08 -03:00
Vijay Dev
6d8c070821 Merge branch 'master' of github.com:lifo/docrails
Conflicts:
	activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
	activerecord/test/cases/adapter_test.rb
	guides/source/testing.md

[ci skip]
2013-03-30 15:46:14 +05:30
Anupam Choudhury
a895b4087d Fixed grammar 2013-03-28 16:43:14 +05:30
Rafael Mendonça França
e7438501d6 Merge pull request #8458 from lucisferre/improve-layout-override-fallback-behavior
Provides standard layout lookup behavior for method and proc cases

Conflicts:
	actionpack/CHANGELOG.md
2013-03-27 16:09:12 -03:00
Chris Nicola
ef27bba63d Provides standard layout lookup behavior for method and proc cases
When setting the layout either by referencing a method or supplying a
Proc there is no way to fall back to the default lookup behavior if
desired. This patch allows fallback to the layout lookup behavior when
returning nil from the proc or method.
2013-03-27 10:59:50 -07:00
Tatsuro Baba
396bb77199 Capitalize the first letter of sentence 2013-03-18 18:31:24 +09:00
Bryan Ricker
fa63f83fd4 Remove :all from *args options in AbstractController.helper 2013-03-16 15:21:42 -07:00
robertomiranda
3bf961d7fd change useless gsub to tr 2013-03-05 09:33:42 -05:00
José Valim
5c1354901e Improve docs for AbsC::Rendering 2013-02-27 08:30:46 -07:00
Carlos Antonio da Silva
2061c98b42 Review #translate docs [ci skip] 2013-01-20 22:49:42 -02:00
Jens Bissinger
37d15d4e1b Add documentation for abstract controller #translate and #localize method. 2013-01-20 19:15:15 +01:00
Gosha Arinich
7a439d23de delegate to :class rather than 'self.class' 2013-01-06 12:43:30 +03:00
Akira Matsuda
370bfda55f replace use of MissingSourceFile with LoadError 2013-01-04 16:46:22 +09:00
Vijay Dev
e0176bf732 Merge branch 'master' of github.com:lifo/docrails 2012-12-21 23:14:08 +05:30
Vijay Dev
6fee8f3ce6 Revert "Fix incorrect adjustment 4c41e87e3ae548c44810b66437b2f0f6e73b2106"
This reverts commit e1f8ec59f2cc83f052b15233147aa2d6d8114a4d.

Reason: seems bad styling

[ci skip]
2012-12-21 23:03:52 +05:30
kei
e1f8ec59f2 Fix incorrect adjustment 4c41e87e3ae548c44810b66437b2f0f6e73b2106 2012-12-20 18:24:31 +09:00
kei
4c41e87e3a Fix documentation style 2012-12-20 18:10:21 +09:00
Andrew White
dcb318ee43 Make conditional_layout? private and update documentation
The conditional_layout? method is not for public use and doesn't
actually do what the documentation suggested it does. It's actually
used to determine whether or not to use the explicit layout definition
defined in a controller or use the implicit layout definition.

Also documentation was added for the action_has_layout? method which
acts as a master switch for disabling the layout for the current
action. This method was added so that action caching didn't depend
on accessing layout internals but is also used by third-parties,
most notably the [Hobo][1] application.

[1]: https://github.com/hobo/hobo
2012-12-17 16:29:38 +00:00
Carlos Antonio da Silva
cff0e51ae9 Refactor helpers code in Action Pack a bit
* 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
2012-12-13 08:46:12 -02:00
Francesco Rodriguez
f53132deea fix prepend_before_filter documentation [ci skip] 2012-12-07 14:28:32 -05:00
David Heinemeier Hansson
9d62e04838 Rename all action callbacks from *_filter to *_action 2012-12-07 18:54:44 +01:00
Alvaro Pereyra
4940d6d096 Cleans and removes useless 'Examples' tag [ci skip] 2012-12-01 15:19:45 -05:00
Vijay Dev
7b70eeed43 Merge branch 'master' of github.com:lifo/docrails
Conflicts:
	actionpack/lib/action_dispatch/routing/redirection.rb
2012-11-17 01:50:49 +05:30
Steve Klabnik
c4e3b0cd8b Removing duplication in callback normalization.
These two things were 100% identical.
2012-11-09 14:43:03 +01:00
AvnerCohen
08d3e534ab Hash Syntax to 1.9 converison 2012-11-07 16:50:10 +02:00
Yves Senn
4d7f53379a cleanup, remove trailing whitespace within actionpack 2012-10-27 16:03:18 +02:00
Aaron Patterson
6033e8aeb0 fix uninitialized ivar warnings 2012-10-25 10:49:13 -07:00
Joshua Peek
c800e27ad3 Merge branch 'master' into asset-path-helper
Conflicts:
	railties/test/application/configuration_test.rb
2012-10-15 10:20:50 -05:00
Joshua Peek
3db69909b9 🔥 Rails asset id support 2012-10-15 09:47:16 -05:00
Nihad Abbasov
ecee64192f remove 'then' from conditional statement 2012-10-14 21:08:25 +06:00
Ayrton De Craene
8d9f9f9dfb Fixed indendation 2012-08-29 10:25:36 +02:00
Sergey Pchelincev
1b5298e805 add lazy look up in abstract controller's translate method 2012-07-18 10:33:14 +03:00
Mircea Pricop
021f3d24f3 Prevent conflict between mime types and Object methods
Assuming the type ":touch", Collector.new was calling
send(:touch), which instead of triggering method_missing
and generating a new collector method, actually
invoked the private method `touch` inherited from
Object.

By generating the method for each mime type as it
is registered, the private methods on Object can
never be reached by `send`, because the `Collector`
will have them before `send` is called on it.

To do this, a callback mechanism was added to Mime::Type

This allows someone to add a callback for whenever
a new mime type is registered. The callback then
gets called with the new mime as a parameter.

This is then used in AbstractController::Collector
to generate new collector methods after each mime
is registered.
2012-07-06 20:38:23 +02:00
Nick Sutterer
1b01ab4959 remove AV.prepare and move all helper-related logic into the controller. this decouples the view since it no longer knows about routes internals.
this is a result of an ongoing discussion at https://github.com/rails/rails/pull/6826.
2012-06-29 11:33:37 +02:00
Aaron Patterson
b9b9e39bab i suck, fixing error message 2012-06-14 09:37:58 -07:00
Aaron Patterson
99c9d18601 Wrap up missing helper exceptions
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).
2012-06-14 09:01:58 -07:00
Aaron Patterson
5d50befa2e using hax to fix tests on Ruby 2.0 2012-06-13 18:01:16 -07:00
Akira Matsuda
099639670a Symbol responds_to :upcase & :downcase in Ruby >= 1.9 2012-06-06 19:33:38 +09:00
Vijay Dev
91305adef8 Merge branch 'master' of github.com:lifo/docrails 2012-05-23 23:26:39 +05:30
Vijay Dev
1ad0b378cc Revert "Remove blank trailing comments"
This reverts commit fa6d921e11363e9b8c4bc10f7aed0b9faffdc33a.

Reason: Not a fan of such massive changes. We usually close such changes
if made to Rails master as a pull request. Following the same principle
here and reverting.

[ci skip]
2012-05-23 22:43:08 +05:30
Vijay Dev
2642c2961c copy edit[ci skip] 2012-05-23 22:42:49 +05:30
Alexey Vakhov
e4569b50d1 Add instance_accessor option to class_attribute 2012-05-22 00:28:34 +04:00
Henrik Hodne
fa6d921e11 Remove blank trailing comments
For future reference, this is the regex I used: ^\s*#\s*\n(?!\s*#). Replace
with the first match, and voilà! Note that the regex matches a little bit too
much, so you probably want to `git add -i .` and go through every single diff
to check if it actually should be changed.
2012-05-20 01:29:13 +02:00
Henrik Hodne
7eb09aed87 Update documentation for AbstractController::Base 2012-05-20 00:50:22 +02:00
Francesco Rodriguez
e471aacf60 removing key argument from run_callbacks - fix build 2012-05-10 02:56:36 -05:00
Edward Tsech
b3bd01c154 Add annotaion for class_eval in AbstractController#helper_method [ci skip] 2012-05-08 11:08:15 +02:00
Edward Tsech
e8d1f10ac4 Improve readability of metaprogramming annotations at AbstractController callbacks. 2012-05-08 09:05:38 +02:00
Vijay Dev
b653c29bbe avoid empty api pages 2012-04-08 01:56:41 +05:30
José Valim
dd0275e463 Add a test case for layout nil. 2012-03-28 23:06:52 +04:00
José Valim
39514af7e7 Merge pull request #5480 from drogus/rendering-issues
Fix for #5440
2012-03-17 11:24:19 -03:00
Piotr Sarnacki
fc6b961b09 Merge pull request #5365 from avakhov/ac-layouts-excpetion-msgs
Fix exceptions messages in AC layouts
2012-03-16 03:25:09 -07:00
Luke Gruber
aca6937760 allow zero-arity proc for AbstrController::layout
proc without parameters can now be given to
AbstractController::layout
2012-03-15 16:40:23 -04:00
Vijay Dev
ab1b352a1c Merge pull request #5421 from parndt/master
Added missing 'end' to documentation example
2012-03-14 05:32:32 -07:00
Philip Arndt
9e8a938047 Added missing end to example 2012-03-14 10:11:55 +13:00
Vijay Dev
800c70a8f9 Merge branch 'master' of github.com:lifo/docrails 2012-03-13 23:29:30 +05:30
Santiago Pastorino
4751a699c9 AbstractController.action_methods should return a Set 2012-03-10 18:37:30 -02:00
Alexey Vakhov
c16f4f1f38 Fix exceptions messages in AC layouts 2012-03-10 09:57:50 +04:00
Alexey Vakhov
23c4efbb5b Fix layout method doc formatting 2012-03-10 09:45:13 +04:00
Alexey Vakhov
2562404624 Fix comment about layout folders lookup 2012-03-09 19:32:43 +04:00
Vijay Dev
7c90d91c3c Clean up module docs [ci skip]
Removed some useless docstrings and no-doc'ed some.
2012-03-07 01:04:14 +05:30
Alexey Vakhov
b27c29ef4a Fix layout lookup for anonymous controller 2012-02-28 14:42:57 +04:00
Vijay Dev
1e25d6217c Merge branch 'master' of github.com:lifo/docrails
Conflicts:
	actionmailer/CHANGELOG.md
2012-02-25 21:52:59 +05:30
Alexey Vakhov
9e1b2d8174 Remove skip_filter block param 2012-02-23 11:25:31 +04:00
Ruben Fonseca
c0ec40c83a Refactored two methods to use delete with a block 2012-02-21 17:04:22 +00:00
Alexey Vakhov
eb26af6dd3 Fix AbstractController#controller_path doc 2012-02-19 11:47:39 +04:00
Alexey Vakhov
774e2c4d9c Fix AbstractController::Base#hidden_actions comment 2012-02-18 11:58:53 +04:00
José Valim
b41ef0a448 Merge pull request #4866 from bogdan/terminate_after_callbacks
AS::Callbacks#define_callbacks: add :terminate_after_callbacks option
2012-02-04 02:53:47 -08:00
Bogdan Gusiev
7661955634 AS::Callbacks: :skip_after_callbacks_if_terminated option 2012-02-03 17:57:53 +02:00
Bogdan Gusiev
1c61f7e6cb AC::Callbacks: remove usage of :per_key option from filters 2012-02-03 14:27:15 +02:00
Sergey Nartimov
5215eed5a3 Symbol#[] method presents in Ruby 1.9 2012-01-07 15:30:36 +03:00
Sergey Nartimov
7d862359d0 get rid of using instance_variable_names method from AS
- instance_variables return symbols in 1.9
- there is instance_variable_defined? method
2012-01-07 14:44:47 +03:00
Rafael Mendonça França
ec28c4fb24 Use Kernel#Array instead of Array.wrap in view_paths 2012-01-05 17:08:18 -03:00
Rafael Mendonça França
1a163dcc41 Array.wrap is no longer needed in AbstractController::Callbacks 2012-01-05 16:48:40 -03:00
José Valim
e6bfcc21a8 Remove unecessary config_accessors. 2011-12-24 09:59:28 +01:00
José Valim
cae1768c6a Remove deprecated layout lookup. 2011-12-20 14:44:48 +01:00
Aaron Patterson
572c3d5178 * BufferedLogger is deprecated. Use ActiveSupport::Logger, or the logger
from Ruby stdlib.
2011-12-19 18:41:37 -08:00
Piotrek Okoński
5266eb9f61 Default relative_url_root to ENV["RAILS_RELATIVE_URL_ROOT"]. Fixes #3365 2011-12-12 17:11:07 +01:00
José Valim
ab30570b69 Fix extend -> include. 2011-12-09 21:42:18 +01:00
José Valim
5ad5215211 Deprecate implicit layout lookup in favor of inheriting the _layout config. 2011-12-09 07:20:55 +01:00
José Valim
67cc07e0c4 Just use the proc if there is a chance of layout lookup. 2011-12-08 16:51:47 +01:00
José Valim
239262fee0 Optimize layout lookup to avoid double calls. 2011-12-08 16:39:06 +01:00
José Valim
efc28a7f70 Some small optimizations and improvements to benchmark code. 2011-12-08 16:39:06 +01:00
Prem Sichanugrist
18ceed201b Allow layout fallback when using layout method
Rails will now use your default layout (such as "layouts/application") when you specify a layout with `:only` and `:except` condition, and those conditions fail.

For example, consider this snippet:

    class CarsController
      layout 'single_car', :only => :show
    end

Rails will use 'layouts/single_car' when a request comes in `:show` action, and use 'layouts/application' (or 'layouts/cars', if exists) when a request comes in for any other actions.
2011-12-06 21:16:29 -05:00
José Valim
fd86a1b6b0 Rely on a public contract between railties instead of accessing railtie methods directly. 2011-11-23 19:06:45 +00:00
Dalibor Nasevic
759906d512 Fixed stale doc in AbstractController::Layouts 2011-11-06 14:43:11 +01:00
Alexey Vakhov
d42d97d2e3 Fix comment in AbstractController callbacks 2011-10-06 10:39:37 +04:00
José Valim
5711a35ad8 Ensure default_asset_host_protocol is respected, closes #2980. 2011-10-05 02:08:02 +02:00
José Valim
6e8fe1bf02 TestCase should respect the view_assigns API instead of pulling variables on its own. 2011-10-02 11:29:13 +02:00
Xavier Noria
bf2b9d2de3 Merge branch 'master' of github.com:lifo/docrails
Conflicts:
	RELEASING_RAILS.rdoc
	actionpack/lib/sprockets/railtie.rb
	actionpack/test/template/sprockets_helper_test.rb
	activerecord/test/cases/calculations_test.rb
	railties/guides/source/3_1_release_notes.textile
	railties/guides/source/active_resource_basics.textile
	railties/guides/source/command_line.textile
2011-08-13 16:30:07 -07:00
geemus
53e1a9d411 update abstract_controller callbacks to document meta-programmed filters 2011-08-13 16:22:35 -07:00
Santiago Pastorino
5b5b22acb5 Remove unused use_sprockets config 2011-08-13 16:22:15 -07:00
Aaron Patterson
5f56db4454 adding missing require to fist railties tests 2011-08-09 14:54:56 -07:00
Aaron Patterson
f9f423fa18 deprecating process_view_paths 2011-08-09 12:10:25 -07:00
Aaron Patterson
3ad26c8e48 avoid object creation via useless duping and freezing 2011-08-09 11:41:06 -07:00
Aaron Patterson
88de343ef4 Array#+ automatically dups, no double duping 2011-08-09 10:54:05 -07:00
Santiago Pastorino
cb85d70d61 Remove unused use_sprockets config 2011-07-25 19:07:39 -03:00
Jon Leighton
fcbde454f6 Don't do remove_possible_method when delegate is used. Two reasons: 1) warnings should be shown, and fixed at the source and 2) the code is slow. Fixes #1937. 2011-07-18 00:22:26 +01:00
Matt Jankowski
db4f0ac025 use present tense on examples 2011-06-21 15:12:11 -04:00
Matt Jankowski
538d2a52ce remove extra space and clarify how an exception is made for controller wide layouts 2011-06-21 10:34:31 -04:00
Matt Jankowski
20a9bddfad reorder layout selection examples to occur in the order that the code does, and provide more detail on why each selection is made 2011-06-21 10:31:16 -04:00
Sebastian Martinez
fcdb5dc557 Remove extra white spaces on ActionPack docs. 2011-05-23 20:22:33 -03:00
Xavier Noria
d491130236 Merge branch 'master' of git://github.com/lifo/docrails
Conflicts:
	actionpack/lib/action_view/helpers/date_helper.rb
	railties/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt
2011-05-14 11:21:27 +02:00
Xavier Noria
e5524d538c minor edits after going through what's new in docrails 2011-05-14 11:15:43 +02:00
Nick Sutterer
e3b3f416b5 added docs for AbC::UrlFor and AC::UrlFor. 2011-05-12 09:31:36 +02:00
Sebastian Martinez
9899f53184 better styling on #available_action? docs 2011-05-06 14:23:25 -03:00
José Valim
9c2c25c1a1 Revert to old semantics, use available_action? instead of action_method?. 2011-05-06 18:44:18 +02:00
José Valim
d42bb68430 More updates to ivars list. 2011-05-06 14:57:25 +02:00
José Valim
894bdbd53d Move variables to underscore format, update protected instance variables list. 2011-05-06 14:57:25 +02:00
José Valim
1632a3a49f More AV::Base cleanup. 2011-05-04 12:07:37 +02:00