Commit Graph

1477 Commits

Author SHA1 Message Date
sonnym
0950d409b0 check for valid options in validate method
This change prevents a certain class of user error which results when
mistakenly using the `validate` class method instead of the `validates`
class method.

Only apply when all arguments are symbols, because some validations use
the `validate` method and pass in additional options, namely the
`LenghValidator` via the `ActiveMode::Validations::validates_with`
method.
2014-07-17 17:32:28 -04:00
Rafael Mendonça França
1a300b6748 Make restore_attributes public
Also make it accept a list of attributes to be changed. This will make
possible to restore only a subset of the changed attributes.

Closes #16203
2014-07-17 14:55:28 -03:00
Rafael Mendonça França
41fb06fa47 Deprecate reset_#{attribute} in favor of restore_#{attribute}.
These methods may cause confusion with the `reset_changes` that
behaves differently
of them.

Also rename undo_changes to restore_changes to match this new set of
methods.
2014-07-15 18:09:38 -03:00
Rafael Mendonça França
66d0a01535 Deprecate ActiveModel::Dirty#reset_changes in favor of #clear_changes_information
This method name is causing confusion with the `reset_#{attribute}`
methods. While `reset_name` set the value of the name attribute for the
previous value the `reset_changes` only discard the changes and previous
changes.
2014-07-15 16:04:31 -03:00
Santosh Wadghule
c890f4f8b2 [ci skip] Little bit doc code improvement. 2014-07-14 10:09:14 +05:30
Godfrey Chan
9eb15ed6a0 Only automatically include validations when enabled
This is a follow up to #16024.
2014-07-02 15:07:57 -07:00
Aditya Kapoor
7b1a42c057 automatically include ActiveModel::Validations when include ActiveModel::SecurePassword 2014-07-03 02:51:12 +05:30
Sean Griffin
fa03fa7735 Silence warning emitted in tests
The instance method `model_name` was being defined multiple times,
causing a redefinition warning.
2014-07-01 07:46:56 -06:00
Rafael Mendonça França
dc67d3d2a1 Rename rollback_changes to undo_changes
To avoid overload with database rollback
2014-06-30 16:55:01 -03:00
Rafael Mendonça França
b34f7c1706 Add CHANGELOG entry for #14861 and document private methods on the API 2014-06-30 15:41:41 -03:00
Rafael Mendonça França
bada1d3ed6 Merge pull request #14861 from igor04/dirty-rollback
Added rollback method to ActiveModel::Dirty
2014-06-30 15:37:06 -03:00
Sean Griffin
36a38973a3 We are talking about the libraries, not the constants 2014-06-27 13:10:58 -06:00
Sean Griffin
e04c4c0820 Note that _will_change! is no longer needed for AR instances
Leave the note for `ActiveModel`, since it can't yet detect mutations
(hopefully we can change this in time for 4.2). However, we now detect
mutations on all supported types in `ActiveRecord`, so we can note that
`_will_change!` is no longer needed there.
2014-06-27 13:07:25 -06:00
Rafael Mendonça França
6099b643e6 Merge pull request #15834 from rmehner/allow_proc_and_symbol_for_only_integer
Allow proc and symbol as values for `only_integer` of `NumericalityValidator`
2014-06-26 07:03:31 -03:00
David Heinemeier Hansson
d5d94a7750 Merge pull request #15871 from yuki24/add-model-name-instance-method
Add #model_name instance method to ActiveModel::Naming
2014-06-24 13:54:58 +02:00
igor04
552d4d85f3 Added rollback method to ActiveModel::Dirty 2014-06-23 23:19:43 +03:00
Aditya Kapoor
d770ec0909 remove unnecessary require for json serialization test cases 2014-06-24 00:03:02 +05:30
Yuki Nishijima
10adc2ee90 Delegate #model_name method to self.class 2014-06-22 19:14:25 -07:00
Robin Mehner
64a05a928c only_integer of NumericalityValidator now allows procs and symbols 2014-06-22 12:22:27 +02:00
Zachary Scott
5b368010f6 ✂️ and 💅 from d60c405 [ci skip] 2014-06-16 11:35:43 -07:00
Aditya Kapoor
eb5d802cab [ci skip] correct doc for serialization in accordance with API Doc Guide 2014-06-16 22:26:55 +05:30
Akshay Vishnoi
73dc6d790c Correct typo, add test for validates_absence_of, correct method names 2014-06-16 08:22:11 +05:30
Godfrey Chan
0ab163d9c6 Edit pass on has_secure_password documentation [ci skip] 2014-06-14 11:05:39 -07:00
Akshay Vishnoi
fb48fccc25 [ci skip] Update #has_secure_password docs 2014-06-14 19:18:24 +05:30
Akshay Vishnoi
9bc91260ac Use @existing_user while updating existing user, fixing - #ee4e86 2014-06-14 14:42:52 +05:30
Godfrey Chan
ee4e86fa4b Cleaned up the has_secure_password test cases
* Grouped the valid test cases in one place
* Make the length of the generated password obvious
* Removed two wrong (copy-and-pasted) test cases
2014-06-14 00:43:47 -07:00
Godfrey Chan
c416bb8729 Added changelog for #15708 [ci skip] 2014-06-14 00:32:31 -07:00
Akshay Vishnoi
cabbc8f6a5 SecurePassword - Validate password must be less than or equal to 72
See #14591, Reason - BCrypt hash function can handle maximum 72 characters.
2014-06-14 12:35:31 +05:30
Arthur Nogueira Neves
6071d626e5 Merge pull request #15690 from deeeki/activemodel_model_doc
[ci skip] Clarify ActiveModel::Model docs
2014-06-13 12:21:46 -05:00
deeeki
8a1468eef6 [ci skip] Clarify ActiveModel::Model docs
ActiveModel attributes initialized with String return String values
2014-06-14 02:13:50 +09:00
Aditya Kapoor
bb075e3839 [ci skip] correct docs for conversion 2014-06-11 23:29:23 +05:30
Aditya Kapoor
2399207789 [ci skip] add tests for ActionModel::Conversion 2014-06-11 23:18:47 +05:30
Vijay Dev
4aa25d4c76 fix typo in changelog [ci skip] 2014-06-11 15:01:28 +05:30
Yves Senn
daaf62c16b Merge pull request #15635 from kuldeepaggarwal/add-missing-changelog
add missing changelog entry. refer [#16db90d] [ci skip]
2014-06-11 09:05:18 +02:00
Kuldeep Aggarwal
aec4127fa1 add missing changelog entry. refer [#16db90d] [ci skip] 2014-06-11 11:38:06 +05:30
Kuldeep Aggarwal
e5cc892ce6 remove depricated Validatior#setup 2014-06-10 12:27:17 +05:30
Zachary Scott
4c66ab2b21 Feature requests should be made on the mailing list, not submitted to
the issue tracker. See also #15455 [ci skip]
2014-06-01 19:11:39 -07:00
Akshay Vishnoi
fd3f3c5348 [ci skip] Include ActiveModel::Model in a class instead of inheriting 2014-05-30 03:09:57 +05:30
ShunsukeAida
33cc907305 Name#model_name doesn't return a String object 2014-05-30 00:09:41 +09:00
Rafael Mendonça França
5508a3e5ca Merge pull request #15154 from msgehard/move_password_field
Put attr_reader in with all of the other instance methods
2014-05-20 20:24:51 -03:00
Mike Gehard
8dd801d6ca Let others know why this code is here
[ci skip]
2014-05-18 06:47:37 -06:00
Mike Gehard
41f7d07da3 Put attr_reader in with all of the other instance methods
This makes the grouping make a little more sense
2014-05-17 13:45:35 -06:00
Yves Senn
8109dc8067 formatting pass through CHANGELOGS. [ci skip] 2014-05-16 09:03:26 +02:00
Abd ar-Rahman Hamidi
6604ce63e8 Add singular and plural form for some validation messages 2014-05-02 18:32:11 +02:00
Robin Dupret
5c87c95a71 Enhance a bit a few changelog entries [ci skip] 2014-05-02 11:56:03 +02:00
hakanensari
9be22bd8d8 Autoload ActiveModel::StrictValidationFailed
Currently, if environment doesn’t eager load code, invoking this
constant before calling #valid? on a model instance results in a
NameError.
2014-04-16 22:48:51 +01:00
Steve Agalloco
e412ccbb56 add missing parentheses to validates_with documentation [skip ci] 2014-04-04 11:54:05 -04:00
Musannif Zahir
8753ce1a37 Fix warning for overshadowing XML variable 2014-03-28 20:11:58 +08:00
David Underwood
d93bfac207 Adds explanation of :base attribute to errors.add
[ci skip]
2014-03-27 16:13:56 -04:00
Rafael Mendonça França
eddcdb0f1d Add CHANGELOG to Active Model too [ci skip] 2014-03-27 14:16:57 -03:00