Commit Graph

42530 Commits

Author SHA1 Message Date
Andrew White
8711086f5a Pull namespace defaults out of the options hash
If a developer has specified either :path or :as in the options hash then
these should be used as the defaults for :shallow_path and :shallow_prefix.

Fixes #14241.
2014-03-08 19:51:06 +00:00
Andrew White
dcc91a04a1 Only use shallow nested scope when depth is > 1
By tracking the depth of resource nesting we can push the need for nested
shallow scoping to only those routes that are nested more than one deep.
This allows us to keep the fix for #12498 and fix the regression in #14224.

Fixes #14224.
2014-03-08 19:51:06 +00:00
Andrew White
ed0fb4ae7e Move setting :scope_level_resource to resource_scope
Originally with_scope_level was exclusively for managing scope levels with
resources, however it is now used for other things so it makes more sense
to move the responsibility for setting the :scope_level_resource to the
resource_scope method. This eliminates repeatedly setting it to the same
resource as each resource method scope is evaluated.
2014-03-08 19:51:06 +00:00
Yves Senn
002c0634d1 Merge pull request #14313 from m-Peter/active_model_doc_fixes
Fix errors for four of the code samples [ci skip]
2014-03-08 20:30:42 +01:00
Peter Markou
f6ab778297 Fix errors for four of the code samples
The four code samples that fail to run are:

- Add attribute magic to objects. Fixed by introducing a Person
  instance variable.

- Tracking value changes. Fixed by replacing `attr_accessor` with
  `define_attribute_methods`, providing getter and setter methods
  for `name` and providing the missing `Person#save` method. A
  call to `Person#save` has to precede the `person.name = 'robert'`
  assignment, if we want `previous_changes` to include 'bob'.

- Adding `errors` interface to objects. Fixed by introducing a
  Person instance variable, assigning `nil` to its name and calling
  `Person#validate!`.

- Custom validators. Fixed by defining `HasNameValidator` before
  it is used by `ValidatorPerson`.

All the code samples can now be run smoothly.

Call Dirty#changes_applied in Person#save, instead of modifying instance vars.
2014-03-08 21:19:42 +02:00
Santiago Pastorino
1fbb9056ef Merge pull request #14325 from robin850/issue-12133
Make the rails:template rake task load initializers
2014-03-08 16:15:12 -02:00
Santiago Pastorino
18c651659e Merge pull request #14244 from arthurnn/orderd_hash_select_fix
Fix OrderedHash.select to return self instance.
2014-03-08 16:12:10 -02:00
Santiago Pastorino
2af7a7b19c Merge pull request #14280 from joho/make_csrf_failure_logging_optional
Make CSRF failure logging optional/configurable.
2014-03-08 15:22:42 -02:00
Robin Dupret
9c53b8b89f Make the rails:template rake task load initializers
Templates could rely on irregular inflections or external libraries for
instance so we should load the application's initializers when running
the rails:template task.

The introducing commit of this feature is f7f11361 ; the initializers
have never been loaded invoking this task.

Fixes #12133.
2014-03-08 15:59:22 +01:00
Yves Senn
dc8bfc8ab6 docs, shorten CsrfHelper description and refer to security guide. [ci skip] 2014-03-08 15:46:43 +01:00
Yves Senn
2883cb9766 added CSRF helper to rails guide documentation. Closes #11615. [ci skip] 2014-03-08 13:41:38 +01:00
Pavel Penkov
62e8145430 Tests for indifferent access using full_messages_for. Closes #11916 2014-03-08 13:28:43 +01:00
Andrew White
5f24446000 Merge pull request #14318 from arthurnn/clean_preview_interceptors
Make sure we clean preview_interceptors
2014-03-07 21:00:17 +00:00
Arthur Neves
d39bba7c85
Make sure we clean preview_interceptors
We should make sure we clean preview_interceptors after each test so they dont leaky to the next test
2014-03-07 14:53:18 -05:00
Arthur Nogueira Neves
5ecb52c36e Merge pull request #14316 from the4dpatrick/master
Add preventDefault() on click event
2014-03-07 14:04:41 -05:00
Patrick Perey
91156b6f0c Add preventDefault() on click event 2014-03-07 10:46:27 -08:00
Arthur Neves
a94966ea09
Fix OrderedHash.select to return self instance.
On ruby 2.1.1 the behavior of .select and .reject has changed.
They will return a Hash new instance, so we need to override them to
keep the instance object class.
2014-03-07 12:30:20 -05:00
Vijay Dev
70ff31d69f Merge branch 'master' of github.com:rails/docrails
Conflicts:
	guides/source/4_1_release_notes.md
2014-03-07 20:58:11 +05:30
dmathieu
3f1699a780 fix typo app -> all
Thank you @bquorning
2014-03-07 15:06:20 +01:00
dmathieu
24434880d9 unscope doesn't remove only the default_scope, but all of them.
[ci-skip]
Closes rails/rails#14294
2014-03-07 14:52:44 +01:00
Vijay Dev
507ee79a6c Merge pull request #14257 from killthekitten/patch-1
Add "Low-Level Caching" part to "Caching With Rails" guide
2014-03-06 22:53:08 +05:30
Aaron Patterson
b7192143ed Merge pull request #14285 from sikachu/master-revert-render-body-remove-content-type
Do note remove `Content-Type` when `render :body`
2014-03-06 08:22:43 -08:00
Yves Senn
2e048bc007 Merge pull request #14296 from joker1007/fix_rails_guides_about_active_record_default_timezone
Fix guide about `config.active_record.default_timezone` [ci skip]
2014-03-06 11:45:04 +01:00
joker1007
64816dacc5 Fix guide about config.active_record.default_timezone [ci skip]
Now the initial value of ActiveRecord.default_timezone is always :utc
2014-03-06 18:59:11 +09:00
Nikolay Shebanov
d361d9303b [ci skip] Add "Low-Level Caching" part to "Caching With Rails" 2014-03-06 00:05:39 +04:00
Hendy Tanata
589d1ed722 Update doc for TagHelper. 2014-03-05 11:54:18 -08:00
Jeremy Kemper
9f84c7bc48 Merge pull request #14101 from sikachu/master-fix-versioning-task
Introduce `Rails.gem_version`
2014-03-05 10:38:48 -07:00
Prem Sichanugrist
2dd2fcf896
Introduce Rails.gem_version
This method return `Gem::Version.new(Rails.version)`, suggesting a more
reliable way to perform version comparison.

Example:

    Rails.version #=> "4.1.2"
    Rails.gem_version #=> #<Gem::Version "4.1.2">

    Rails.version > "4.1.10" #=> false
    Rails.gem_version > Gem::Version.new("4.1.10") #=> true
    Gem::Requirement.new("~> 4.1.2") =~ Rails.gem_version #=> true

This was originally introduced as `.version` by @charliesome in #8501
but got reverted in #10002 since it was not backward compatible.

Also, updating template for `rake update_versions`.
2014-03-05 12:37:38 -05:00
Prem Sichanugrist
ed88a601f7
Do note remove Content-Type when render :body
`render :body` should just not set the `Content-Type` header. By
removing the header, it breaks the compatibility with other parts.

After this commit, `render :body` will returns `text/html` content type,
sets by default from `ActionDispatch::Response`, and it will preserve
the overridden content type if you override it.

Fixes #14197, #14238

This partially reverts commit 3047376870d4a7adc7ff15c3cb4852e073c8f1da.
2014-03-05 10:33:52 -05:00
Robin Dupret
058d3c6183 Remove a reference to an issue [ci skip]
This actually not an issue fixing ; the changelog is referring to the
introducing pull request itself.
2014-03-05 14:00:23 +01:00
Yves Senn
b74eed58b2 get rid of intermediate arrays.
origin: f6aeb8b1a3 (commitcomment-5569649)
2014-03-05 10:45:37 +01:00
Yves Senn
f6aeb8b1a3 we only need to support asc and ASC. No need for mixed cases. #14263
This is a result of the discussion at https://github.com/rails/rails/pull/14263/files#r10291489
2014-03-05 10:24:13 +01:00
Yves Senn
8d486c63d6 docs, flash message keys are normalized to strings. [ci skip]
This is a follow up to a668beffd64106a1e1fedb71cc25eaaa11baf0c1
2014-03-05 09:53:39 +01:00
Yves Senn
54a120ed55 quick pass over Active Record CHANGELOG. [ci skip]. 2014-03-05 09:07:12 +01:00
Yves Senn
5f7f3bb1df Merge pull request #14263 from robin850/allow_passing_string_to_order_hash
Follow up of #10732 - Allow string hash values on AR order method
2014-03-05 09:05:15 +01:00
Aaron Patterson
ef7e7ad7e9 Merge pull request #14261 from MSch/bound-parameters-for-exists
Make exists? use bound values.
2014-03-04 19:59:58 -08:00
Godfrey Chan
ccf8f27ddd Revert "Merge pull request #14269 from arthurnn/expanded_key_array"
This reverts commit 475c96589ca65282e1a61350271c2f83f0d4044f, reversing
changes made to 705915ab5cf24430892107764b0050c07e1df583.

We decided that this is not worth busting everyone's cache as this
seems like a very unlikely problem. The problem only occurs when the
user is 1) not using a namespace, or 2) using the same namesapce for
different *kinds* of cache items. The recommended "fix" is to put
those cache items into their own namspace:

    id = 1
    Rails.cache.fetch(id, namespace: "user"){ User.find(id) }

    ids = [1]
    Rails.cache.fetch(ids, namespace: "users"){ User.find(ids) }

See the discussion on #14269 for details.
2014-03-04 17:58:58 -08:00
John Barton (joho)
67584c6ae3 Make CSRF failure logging optional/configurable.
Added the log_warning_on_csrf_failure option to ActionController::RequestForgeryProtection
which is on by default.
2014-03-05 11:31:57 +11:00
Guillermo Iguaran
475c96589c Merge pull request #14269 from arthurnn/expanded_key_array
Cache key should be different when is Array.
2014-03-04 17:11:34 -05:00
Marcelo Casiraghi
acbd7ab22e Allow string hash values on AR order method
This behavior has almost no performance impact:

String not allowed  66.910000   0.030000  66.940000 ( 67.024976)
String allowed      69.360000   0.030000  69.390000 ( 69.503096)

Benchmarked with http://git.io/Y0YuRw.
2014-03-04 18:20:00 +01:00
David Heinemeier Hansson
705915ab5c Merge pull request #14243 from pch/digestor-variants
Variants in ActionView::Digestor
2014-03-04 16:15:26 +01:00
Carlos Antonio da Silva
ab1bd7ccf1 Always return an array from formats so there is no need to wrap it when calling 2014-03-04 11:26:09 -03:00
Allen Fair
3624ff720c Fix for external generators extend Erb::Generators
HAML and probably other generators extend this class and invoke
filename_with_extensions with the old signature (without format).
This makes the second argument optional and defaults it to the #format
method which could be overridden as well.

Closes #14132.
2014-03-04 11:25:52 -03:00
Piotr Chmolowski
1858cc6070 Variants in ActionView::Digestor
Take variants into account when calculating template digests in
ActionView::Digest.

Digestor#digest now takes a hash as an argument to support variants and
allow more flexibility in the future. Old-style arguments have been
deprecated.

Fixes #14242
2014-03-04 15:02:58 +01:00
Carlos Antonio da Silva
8ed0f542dd Inline block to fix indent [ci skip] 2014-03-04 09:50:39 -03:00
Yves Senn
18db6a70be Merge pull request #14273 from vipulnsward/fix-warning-13244
Fix enum test unused variable warning.
2014-03-04 13:38:30 +01:00
Vipul A M
6e66de6091 Fix enum test unused variable warning.
Related - 5c55aafd38
2014-03-04 18:06:19 +05:30
Yves Senn
9ada39f62e Merge pull request #13244 from kommen/pg_enum_type_map
Add Enum type to postgresql adapter's oids to prevent unknown OID warnings
2014-03-04 13:14:41 +01:00
Carlos Antonio da Silva
7231a135ea Use 1.9 style hash on docs [ci skip] 2014-03-04 08:25:15 -03:00
Carlos Antonio da Silva
8b1ccd5949 Simplify handling of defaults/options in button_tag
There's no need to rely on Active Support's Hash#reverse_merge for
simple cases with default values, since we can just merge from the
default rather than reverse merge from the options.

This also avoids the creation of one extra hash object by moving to a
Hash#merge! call.
2014-03-04 08:23:00 -03:00