Commit Graph

41899 Commits

Author SHA1 Message Date
Yves Senn
75cd7bc3c2 Merge pull request #13728 from semenyukdmitriy/master
Added missing `file` delivery method to the Configuration Guide
2014-01-22 01:53:30 -08:00
Semenyuk Dmitriy
9e63ead4ae [ci skip] Added missing file delivery method 2014-01-22 15:50:01 +06:00
Rafael Mendonça França
a4ce065943 Merge pull request #13786 from terracatta/master
Ensure AR #second, #third, etc. finders work through associations
2014-01-21 16:45:08 -08:00
Rafael Mendonça França
fc913d4016 Fix typo 2014-01-21 22:38:07 -02:00
Jason Meller
03855e790d Ensure AR #second, #third, etc. finders work through associations
This commit fixes two regressions introduced in cafe31a078 where
newly created finder methods #second, #third, #forth, and #fifth
caused a NoMethodError error on reload associations and where we
were pulling the wrong element out of cached associations.

Examples:

  some_book.authors.reload.second

  # Before
  # => NoMethodError: undefined method 'first' for nil:NilClass

  # After
  # => #<Author id: 2, name: "Sally Second", ...>

  some_book.first.authors.first
  some_book.first.authors.second

  # Before
  # => #<Author id: 1, name: "Freddy First", ...>
  # => #<Author id: 1, name: "Freddy First", ...>

  # After
  # => #<Author id: 1, name: "Freddy First", ...>
  # => #<Author id: 2, name: "Sally Second", ...>

Fixes #13783.
2014-01-21 19:35:27 -05:00
Rafael Mendonça França
9383de42a2 Merge pull request #13776 from rails/dirty-enum
Implement the Dirty API with the Enum feature correctly.

Conflicts:
	activerecord/CHANGELOG.md
2014-01-21 20:37:45 -02:00
Rafael Mendonça França
55f6c8c908 Use string as keys 2014-01-21 20:35:21 -02:00
Rafael Mendonça França
5620e62f3f Store the enum values in the DEFINED_ENUM constant
This will make simpler to compare if the values changed in the
save_changed_attribute method.
2014-01-21 20:32:52 -02:00
Rafael Mendonça França
c6ecfc1668 Merge pull request #13784 from kuldeepaggarwal/fix-doc-collection-proxy
Add missing information for `id` field when used with `select` [ci skip]
2014-01-21 13:39:55 -08:00
Kuldeep Aggarwal
7e25da9eed add missing information for id field when used with select [ci skip] 2014-01-22 02:50:23 +05:30
Rafael Mendonça França
b0a8ef140e has_one and belongs_to accessors don't add ORDER BY to the queries anymore.
Since Rails 4.0, we add an ORDER BY in the `first` method to ensure consistent
results among different database engines. But for singular associations this
behavior is not needed since we will have one record to return. As this
ORDER BY option can lead some performance issues we are removing it for singular
associations accessors.

Fixes #12623.
2014-01-21 14:41:52 -02:00
Yves Senn
e011258c30 prepend table name for Relation#select columns.
This fixes a bug where `select(:id)` combined with `joins()` raised:

```
ActiveRecord::StatementInvalid: SQLite3::SQLException: ambiguous column name: id:
SELECT  id, authors.author_address_id
FROM "posts"
INNER JOIN "authors"
ON "authors"."id" = "posts"."author_id"
ORDER BY posts.id LIMIT 3
```

The `select_values` are still String and Symbols because other parts (mainly calculations.rb)
rely on that fact.

/cc @tenderlove
2014-01-21 17:21:20 +01:00
Rafael Mendonça França
a0520fceff Add more tests for the dirty feature for enums 2014-01-21 12:45:58 -02:00
Rafael Mendonça França
a57a2bcf4a Make enum feature work with dirty methods
To make this possible we have to override the save_changed_attribute
hook.
2014-01-21 12:45:53 -02:00
Rafael Mendonça França
a4cc88d085 Extract all attribute changed work to its own method
This will make easier to hook on this feature to customize the behavior
2014-01-21 12:45:06 -02:00
Yves Senn
c60e06261b Merge pull request #13696 from senny/engine_bin_rails_load_bundler
setup Bundler in engines `bin/rails` stub.
2014-01-21 05:58:01 -08:00
Yves Senn
6f0aa1d64d Active Record changelog wording and formatting. [ci skip] 2014-01-21 14:35:33 +01:00
Yves Senn
6a8a7f89ae Merge pull request #9969 from divineforest/fix-find-in-batches
Fail early with "Primary key not included in the custom select clause" i...
2014-01-21 05:31:27 -08:00
Alexander Balashov
691709dd67 Fail early with "Primary key not included in the custom select clause" in find_in_batches
Before this patch find_in_batches raises this error only on second iteration. So you will know about the problem only when you get the batch size threshold.
2014-01-21 17:27:34 +04:00
Carlos Antonio da Silva
9322e071e4 Remove missed usage of @first variable
With the introduction of `#second` method and friends, we added an
offsets hash which replaced the @first variable, so removing it from the
reset method to avoid creating an unused variable now.

Introduced in bc625080308e4853ae3036f2ad74fe3826e463ef.
2014-01-21 09:46:02 -02:00
Rafael Mendonça França
b8302bcfda Forgot to push this change in the parent commit 2014-01-20 23:00:17 -02:00
Rafael Mendonça França
06a00038ef When applying changes or reseting changes create the right class
Before this patch after the changes are applied the changes can be only
accessed using string keys, but before symbols are also accepted.

After this change every state of the model will be consistent.
2014-01-20 22:58:14 -02:00
Rafael Mendonça França
de3bf3ec3d Remove unneded argument
This variable is internal and should not be exposed to end users
2014-01-20 20:48:00 -02:00
Rafael Mendonça França
bc62508030 Merge pull request #13757 from terracatta/master
Ensure #second (and others) acts like #first AR finder
2014-01-20 20:44:02 -02:00
Jason Meller
cafe31a078 Ensure #second acts like #first AR finder
This commit bring the famous ordinal Array instance methods defined
in ActiveSupport into ActiveRecord as fully-fledged finders.

These finders ensure a default ascending order of the table's primary
key, and utilize the OFFSET SQL verb to locate the user's desired
record. If an offset is defined in the query, calling #second adds
to the offset to get the actual desired record.

Fixes #13743.
2014-01-20 16:58:18 -05:00
Rafael Mendonça França
5a09f13a34 Merge branch 'anilmaurya-master' 2014-01-20 16:51:14 -02:00
anilmaurya
41722dd444 moving controller_name assignment before model name condition 2014-01-20 16:50:29 -02:00
Andrew White
bf191318af Tidy up tests and CHANGELOG for #12598 2014-01-20 16:34:22 +00:00
Mikko Johansson
f9f32e04ad Automatically convert dashes to underscores in shorthand routes 2014-01-20 15:37:23 +00:00
Amr Tamimi
746abbcc31 Automatically convert dashes to underscores for url helpers 2014-01-20 15:24:30 +00:00
Yves Senn
080fc9cad3 docs should say email not Email. [ci skip] 2014-01-20 15:04:36 +01:00
Yves Senn
dfac4ced1d docs, hyperlink the Mail gem in Action Mailer guide. [ci skip] 2014-01-20 14:47:40 +01:00
Yves Senn
079ffc96c1 let's link to the gem README not to the upgrading guide. [ci skip]
The PR #13767 added link to the upgrading guide to explain
details about activerecord_deprecated-finders. However the link target
features a stack of changes not releated at all. Also the relevant details
are not very informative.

I think we better link to the README so people can see what the gem is about
and how to use it.

/cc @chancancode @zzak
2014-01-20 14:06:37 +01:00
Carlos Antonio da Silva
f63c6e57ee Fix secrets.yml path in exception message
The file is config/secrets.yml, not config/initializers/secrets.yml.
2014-01-20 08:58:43 -02:00
Godfrey Chan
06849fd4d0 Merge pull request #13767 from zzak/doc_4_1_release_notes_deprecated_finders
Add link to upgrade guide for full list of deprecated finders [ci skip]
2014-01-20 02:03:58 -08:00
Godfrey Chan
54befc691c Merge pull request #13769 from arelenglish/fix_typo_upgrad_guide
Fix a typo that says you application [ci skip]
2014-01-19 21:41:29 -08:00
Arel English
7f255245bd Fix a typo that says you application [ci skip] 2014-01-20 00:37:48 -05:00
Godfrey Chan
27f1fd093a Merge pull request #13768 from rajeshthummalapally/rails_blog_correct_patch_link
Fix for incorrect link that is pointing to Rails blog [ci skip]
2014-01-19 21:14:34 -08:00
Rajesh Thummalapally
610a3e8bdb Correcting link that is pointing to Rails blog [ci skip] 2014-01-19 23:47:48 -05:00
Guillermo Iguaran
18e9188709 Merge pull request #13765 from robertomiranda/secrets_token
Update Error Message when secrets.secret_key_base isn't given
2014-01-19 20:08:32 -08:00
robertomiranda
90228a168b Update Error Message when secrets.secret_key_base isn't given 2014-01-19 22:29:34 -05:00
Zachary Scott
9040e04c72 Add link to upgrade guide for full list of deprecated finders [ci skip] 2014-01-19 18:43:51 -08:00
Rafael Mendonça França
b1b21f9325 Merge pull request #13745 from nextgearcapital/master
set encoding for pipe to binary mode
2014-01-19 10:24:22 -08:00
Robin Dupret
935d235f90 Merge pull request #13762 from robertomiranda/spring-under-rails
Update Changelog, Spring is under rails/spring [ci skip]
2014-01-19 06:55:39 -08:00
robertomiranda
7671590fe2 Update Changelog, Spring is under rails/spring [ci skip] 2014-01-19 08:50:15 -05:00
Robin Dupret
0c96f8abb8 Merge pull request #13759 from raysrashmi/rails-spring
Spring in now under rails/spring [ci skip]
2014-01-19 02:02:02 -08:00
Rashmi Yadav
b20d4453dd Spring in now under rails/spring [ci skip] 2014-01-19 10:52:49 +01:00
Andrew White
ab91bc3192 Merge pull request #13756 from huoxito/rails-spring
spring gem moved to rails/spring
2014-01-19 01:36:09 -08:00
Washington Luiz
e05c791264 spring gem moved to rails/spring 2014-01-18 20:22:51 -03:00
Godfrey Chan
3c354bd83b Merge pull request #13751 from chancancode/ar_rollback_fix
Restore ActiveRecord states after a rollback for models w/o callbacks
2014-01-18 14:26:17 -08:00