Commit Graph

89 Commits

Author SHA1 Message Date
Matthew Draper
e213b37fc1 Merge pull request #16210 from sonnym/assert_valid_keys_in_validate
Check for valid options in validate method
2014-07-18 07:10:49 +09:30
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
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
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
Robin Mehner
64a05a928c only_integer of NumericalityValidator now allows procs and symbols 2014-06-22 12:22:27 +02:00
Godfrey Chan
c416bb8729 Added changelog for #15708 [ci skip] 2014-06-14 00:32:31 -07:00
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
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
Rafael Mendonça França
eddcdb0f1d Add CHANGELOG to Active Model too [ci skip] 2014-03-27 14:16:57 -03:00
Carlos Antonio da Silva
71b3910a7d Point master changelogs to 4-1-stable branch
Remove 4-1 related entries from master [ci skip]
2014-02-25 09:14:36 -03:00
Yves Senn
7d196cf360 #to_param returns nil if to_key returns nil. Closes #11399.
The documentation of `#to_key` (http://api.rubyonrails.org/classes/ActiveModel/Conversion.html#method-i-to_key)
states that it returns `nil` if there are no key attributes. `to_param` needs
to be aware of that fact and return `nil` as well.

Previously it raised the following exception:

```
  1) Error:
ConversionTest#test_to_param_returns_nil_if_to_key_is_nil:
NoMethodError: undefined method `join' for nil:NilClass
    /Users/senny/Projects/rails/activemodel/lib/active_model/conversion.rb:65:in `to_param'
    /Users/senny/Projects/rails/activemodel/test/cases/conversion_test.rb:34:in `block in <class:ConversionTest>'
```
2014-02-04 10:27:46 +01:00
Yves Senn
02f9f33142 tidy CHANGELOGs [ci skip] 2014-01-30 11:12:46 +01:00
Vince Puzzella
8855163bdb Ability to specify multiple contexts when defining a validation.
Example:

validates_presence_of :name, on: [:update, :custom_validation_context]
2014-01-27 03:26:27 -05:00
Carlos Antonio da Silva
3a33e8ea85 Use a better method name to check the requirement of password confirmation
Also improve changelog entries related to secure password to proper
highlight.
2014-01-07 07:59:44 -02:00
Tejas Dinkar
da2b05bb6b Allows you to check if an attribute has changed to a particular value
model.name_changed?(from: "Pete", to: "Ringo")
2013-12-15 12:13:31 +05:30
Yves Senn
7c6d99e81e first pass through CHANGELOGS to extract 4_1_release_notes. [ci skip]
Extract **notable changes**, **deprecations** and **removals** from
each CHANGELOG.

I tried to reference the commits and pull requests for new features
and deprecations.

In the process I also made some minor changes to the CHANGELOGS.

The 4_1_release_notes guide is declared WIP.
2013-11-28 17:24:15 +01:00
T.J. Schuck
5d7b413d84 Use bcrypt's public cost attr, not internal constant
See:

- https://github.com/codahale/bcrypt-ruby/pull/63
- https://github.com/codahale/bcrypt-ruby/pull/64
- https://github.com/codahale/bcrypt-ruby/pull/65
2013-10-10 11:46:59 -04:00
Rafael Mendonça França
c48c111bb2 Merge pull request #8791 from griffinmyers/master
Updated DirtyModel's @changed_attributes hash to be symbol/string agnostic

Conflicts:
	activemodel/CHANGELOG.md
2013-10-03 11:37:10 -03:00
Rafael Mendonça França
7ef29140eb No need to abbreviate ActiveModel
[ci skip]
2013-09-23 11:01:43 -03:00
Rafael Mendonça França
9aa1a3d853 Merge pull request #10816 from bogdan/less-dirty-dirty
Make AM::Dirty less dirty to plugin into AR or other library
2013-09-23 10:59:05 -03:00
Vladimir Kiselev
3be0cdfa55 Fix secure_password password_confirmation validations 2013-07-24 03:14:15 +04:00
Carlos Antonio da Silva
61346d1b42 Merge pull request #10774 from chuckbergeron/validates-inclusion-of-accuracy-for-non-numeric-ranges
Greater accuracy for validates_inclusion_of on non-numeric ranges

Closes #10774, fixes #10593
2013-06-25 21:48:41 -03:00
Phil Calvin
5d93ef8f45 Fix regression in has_secure_password.
If the confirmation was blank, but the password wasn't, it would still save.
2013-05-30 11:18:43 -07:00
Charles Bergeron
0317b93c17 Use Range#cover? for Numeric ranges (tests via endpoints) and use Range#include? for non-numeric ranges
added changelog message
2013-05-27 23:54:25 -07:00
William Myers
0e655873d4 DirtyModel uses a hash to keep track of any changes made to attributes
of an instance. When using the attribute_will_change! method, you must
supply a string and not a symbol or the *_changed? method will break
(because it is looking for the attribute name as a string in the keys
of the underlying hash). To remedy this, I simply made the underlying
hash a HashWithIndifferentAccess so it won't matter if you supply
the attribute name as a symbol or string to attribute_will_change!.
2013-05-27 23:41:26 -04:00
Nick Sutterer
7d84c3a2f7 deprecate Validator#setup (to get rid of a respond_to call). validators do their setup in their constructor now. 2013-05-23 10:00:44 -03:00
Rafael Mendonça França
feb44b9213 rails/master is now 4.1.0.beta 2013-04-29 13:15:24 -03:00
Yves Senn
c245437de7 use unified and clean formatting in CHANGELOGS. [ci skip] 2013-04-12 15:52:43 +02:00
Carlos Antonio da Silva
3d0c0c6c95 Improve changelog entry for ActiveModel::Errors#full_messages_for [ci skip]
Add a working example of how to use this new method.
2013-03-30 14:38:13 -03:00
shock_one
ec1b715b0e Add a method full_messages_for to the Errors class 2013-03-24 09:38:28 +02:00
Prathamesh Sonpatki
5f59317ec6 Fixed typo in activemodel/CHANGELOG 2013-03-24 02:27:43 +05:30
wangjohn
3ee30ca44a The repair_validations helper was not working correctly before because
it only cleared the validations that created :validate callbacks. This
didn't include the validates created by validates_with, so I've added a
method to clear all validations.
2013-03-19 12:23:20 -04:00
Vipul A M
29dcf096b0 Small typos here and there. 2013-03-15 11:55:03 +05:30
Carlos Antonio da Silva
b3a31e9363 Fix AMo code example indent, add missing author to entry [ci skip] 2013-03-09 14:57:31 -03:00
Yves Senn
8c1687bbf8 has_secure_password is not invalid when assigning empty Strings.
Closes #9535.

With 692b3b6 the `password=` setter does no longer set blank passwords.
This triggered validation errors when assigning empty Strings to `password`
and `password_confirmation`.

This patch only sets the confirmation if it is not `blank?`.
2013-03-04 18:56:05 +01:00
Yves Senn
b501ee47fa validates_confirmation_of does not override writer methods. 2013-03-04 18:51:34 +01:00
Rafael Mendonça França
0f75e2c51f Update CHANGELOGS 2013-02-26 13:45:57 -03:00
David Heinemeier Hansson
c0bc9ce38c Preparing for 4.0.0.beta1 release 2013-02-25 08:31:50 -06:00
Xavier Noria
05857ec30e did a pass over the AM changelog [ci skip] 2013-02-24 20:37:15 +01:00
Rafael Mendonça França
b05819fd28 This change doesn't need a CHANGELOG entry.
[ci skip]
2012-12-26 20:39:32 -03:00
Rafael Mendonça França
9647d4b6f4 Add CHANGELOG entry for #8622 2012-12-26 19:22:38 -03:00
Rafael Mendonça França
bda1937f28 Remove CHANGELOG entry for ActiveModel::Errors#add_on_present 2012-12-21 17:10:41 -03:00
Carlos Antonio da Silva
42b555dcf3 Fix Action Mailer changelog indenation to match other changelogs
Also some minor improvements to other changelogs. [ci skip]
2012-12-19 23:09:04 -02:00
Carlos Antonio da Silva
05b80a1cce Improve AMo changelog example to not rely on AR [ci skip] 2012-12-19 23:03:32 -02:00