Commit Graph

41877 Commits

Author SHA1 Message Date
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
Godfrey Chan
7386ffc781 Restore ActiveRecord states after a rollback for models w/o callbacks
This fixes a regression (#13744) that was caused by 67d8bb9.

In 67d8bb9, we introduced lazy rollback for records, such that the
record's internal states and attributes are not restored immediately
after a transaction rollback, but deferred until they are first
accessed.

This optimization is only performed when the model does not have any
transactional callbacks (e.g. `after_commit` and `after_create`).

Unfortunately, the models used to test the affected codepaths all
comes with some sort of transactional callbacks. Therefore this
codepath remains largely untested until now and as a result there are
a few issues in the implementation that remains hidden until now.

First, the `sync_with_transaction_state` (or more accurately,
`update_attributes_from_transaction_state`) would perform the
synchronization prematurely before a transaction is finalized (i.e.
comitted or rolled back). As a result, when the actuall rollback
happens, the record will incorrectly assumes that its internal states
match the transaction state, and neglect to perform the restore.

Second, `update_attributes_from_transaction_state` calls `committed!`
in some cases. This in turns checks for the `destroyed?` state which
also requires synchronization with the transaction stae, which causes
an infnite recurrsion.

This fix works by deferring the synchronization until the transaction
has been finalized (addressing the first point), and also unrolled
the `committed!` and `rolledback!` logic in-place (addressing the
second point).

It should be noted that the primary purpose of the `committed!` and
`rolledback!` methods are to trigger the relevant transactional
callbacks. Since this code path is only entered when there are no
transactional callbacks on the model, this shouldn't be necessary. By
unrolling the method calls, the intention here (to restore the states
when necessary) becomes more clear.
2014-01-18 11:16:52 -08:00
Richard Schneeman
35b85d2e7d Merge pull request #13748 from summerblue/master
Correct the version number to 4 in guides[ci skip]
2014-01-17 20:24:47 -08:00
Charlie Jade
bf89bfdc34 Correct the version number to 4 in guides[ci skip] 2014-01-18 12:14:21 +08:00
Aaron Patterson
1543863548 fix exception translation 2014-01-17 14:09:27 -08:00
Aaron Patterson
9bc303cae2 translate exceptions on prepared statement failure 2014-01-17 14:09:14 -08:00
Aaron Patterson
c1bbf1b2e4 test to ensure bad prepared statements raise a StatementInvalid exception 2014-01-17 14:08:00 -08:00
Anna Carey
0e9144dcec set encoding to binmode for pipe 2014-01-17 16:49:10 -05:00
Carlos Antonio da Silva
486db21f91 Fix eager load of Serializers on Active Model 2014-01-17 15:30:09 -02:00
Rafael Mendonça França
a49727213c Consistence in the block style 2014-01-17 00:30:41 -02:00
Rafael Mendonça França
5402b72faa Remove warnings on Ruby 2.1 2014-01-17 00:10:25 -02:00
Rafael Mendonça França
7252b43c6e Only some dynamic finders are deprecated.
find_by_* and find_by_*! are not deprecated for example, so lets add a
note only where it is needed

[ci skip]
2014-01-16 22:12:37 -02:00
Lauro Caetano
b9acc4a838 Merge pull request #13735 from xta/cleanup_security_guide
clean up security guide: his => their [ci skip]
2014-01-16 16:04:22 -08:00
Rex Feng
beeb8969e0 clean up security guide: his => their [ci skip] 2014-01-16 18:57:21 -05:00
Rafael Mendonça França
bcd6def32b Remove warning 2014-01-16 20:36:38 -02:00
Rafael Mendonça França
662f8de06f Merge pull request #13414 from britto/jb-fix-dependency-matching
Improve ERB dependency detection
2014-01-16 13:38:12 -08:00
Carlos Antonio da Silva
49223c9bc9 Extract a method to simplify setup code 2014-01-16 18:52:43 -02:00
Carlos Antonio da Silva
740cf33b5e Use minitest's skip rather than conditionals + early returns 2014-01-16 18:48:51 -02:00
Carlos Antonio da Silva
44e5551054 Move AR test classes inside the test case 2014-01-16 18:45:03 -02:00
Carlos Antonio da Silva
c9c4a427e1 Do not set up a variable used only in two tests
Just create a local variable whenever we need the record, rather than
doing an extra find for every test on the setup method.
2014-01-16 18:40:18 -02:00
Carlos Antonio da Silva
07ff3525d5 No need for instance vars on single tests 2014-01-16 18:40:18 -02:00
Carlos Antonio da Silva
da4b5e8ecb Cleanup duplicated setup of callbacks in transactions tests 2014-01-16 18:40:18 -02:00