aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel
Commit message (Collapse)AuthorAgeFilesLines
* Remove package:clean taskJavan Makhmali2016-05-241-1/+0
| | | | Introduced in d6f2000a67cc63aa67414c75ce77de671824ec52 and was only used by Action Cable. Now handled by Action Cable’s assets:compile task.
* Support for unified Integer class in Ruby 2.4+Jeremy Daer2016-05-182-2/+2
| | | | | | | | Ruby 2.4 unifies Fixnum and Bignum into Integer: https://bugs.ruby-lang.org/issues/12005 * Forward compat with new unified Integer class in Ruby 2.4+. * Backward compat with separate Fixnum/Bignum in Ruby 2.2 & 2.3. * Drops needless Fixnum distinction in docs, preferring Integer.
* - removing redundant 'happens' in documentation [ci skip]Mohit Natoo2016-05-191-4/+2
|
* Merge branch 'master' of github.com:rails/docrailsVijay Dev2016-05-141-2/+11
|\ | | | | | | | | Conflicts: guides/source/configuring.md
| * Add example for UnknownAttributeErrorVipul A M2016-05-021-0/+9
| | | | | | | | [ci skip]
| * Active Model: Messages for strict validation always convert attributes to ↵Prathamesh Sonpatki2016-05-011-2/+2
| | | | | | | | human readable form [ci skip]
* | Start Rails 5.1 development :tada:Rafael Mendonça França2016-05-102-157/+3
| |
* | Preparing for 5.0.0.rc1 releaseRafael Mendonça França2016-05-062-1/+6
| |
* | Merge pull request #24799 from prathamesh-sonpatki/18439-followupRafael França2016-05-051-4/+6
|\ \ | | | | | | Active Model: Improve CHANGELOG and documentation for `validates_acceptance_of` [ci skip]
| * | Active Model: Improve CHANGELOG and documentation for ↵Prathamesh Sonpatki2016-05-051-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `validates_acceptance_of` [ci skip] - Improve CHANGELOG entry for #18439. - The documentation is updated as per changes in PR #18439 to the `accept` option. - The explanation about the virtual attribute is moved at the end so that the arity of `accept` option is explained first. - Added a note that `message` can also be passed to `validates_acceptance_of`.
* | | Merge pull request #24806 from vipulnsward/errors-details-testRafael França2016-05-051-1/+1
|\ \ \ | | | | | | | | Followup of #18322
| * | | Followup of #18322Vipul A M2016-05-021-1/+1
| |/ / | | | | | | | | | Mirror the documented new behavior of including details, when performing errors test.
* | | Check for the right exceptionRafael Mendonça França2016-05-031-1/+1
| | |
* | | Change RangeError to a more specific ActiveModel::RangeErrorChristian Blais2016-05-034-7/+12
|/ / | | | | | | | | | | The should make it easier for apps to rescue ActiveModel specific errors without the need to wrap all method calls with a generic rescue RangeError.
* / Chomp: prefer String#chomp where we can for a clarity boostlvl0nax2016-04-292-6/+2
|/ | | | | | Closes #24766, #24767 Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
* Prep Rails 5 beta 4eileencodes2016-04-272-1/+3
|
* - [ci skip] `regardless` is usually followed by `of` and not by `if .. or not`.Mohit Natoo2016-04-211-2/+2
|
* Fixed bug introduced in #24519. Makes build green againBogdan Gusiev2016-04-131-1/+1
|
* Use keyword arguments to cleanup without droping performanceBogdan Gusiev2016-04-131-8/+8
|
* prevent 'attribute_changed?' from returning nilSen-Zhang2016-04-111-1/+1
|
* Merge pull request #24511 from lihanli/activemodel-dirty-attribute-changedJeremy Daer2016-04-111-3/+5
|\ | | | | speed up ActiveModel::Dirty#attribute_changed?
| * set default parameter to nil to speed up attribute_changed?Lihan Li2016-04-111-3/+5
| | | | | | | | | | | | | | | | | | | | | | Benchmark results: Warming up -------------------------------------- old code 32.176k i/100ms new code 34.837k i/100ms Calculating ------------------------------------- old code 1.595M (± 3.5%) i/s - 7.947M new code 1.942M (± 3.9%) i/s - 9.685M
* | Pass over all Rails 5 warnings, to make sure:Vipul A M2016-04-121-2/+2
|/ | | | | | | | | | - we are ending sentences properly - fixing of space issues - fixed continuity issues in some sentences. Reverts https://github.com/rails/rails/commit/8fc97d198ef31c1d7a4b9b849b96fc08a667fb02 . This change reverts making sure we add '.' at end of deprecation sentences. This is to keep sentences within Rails itself consistent and with a '.' at the end.
* fix length validation error typoPareshGupta2016-04-071-1/+1
|
* Add test case for interpolation with passing of data along with record ↵Vipul A M2016-04-051-0/+8
| | | | attribute in error message, where a proc is passed.
* Allow passing record being validated to error message generatorPrathamesh Sonpatki2016-04-053-1/+15
| | | | | | | | | - Pass object to I18n helper so that when calling message proc, it will pass that object as argument to the proc and we can generate custom error messages based on current record being validated. - Based on https://github.com/rails/rails/issues/856. [Łukasz Bandzarewicz, Prathamesh Sonpatki]
* Merge pull request #24299 from kitop/activemodel-errors-include-fixKasper Timm Hansen2016-03-252-1/+8
|\ | | | | Do not create a hash key when calling ActiveModel::Errors#include?
| * Do not create a hash key when calling ActiveModel::Errors#include?Esteban Pastorino2016-03-242-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From: https://github.com/rails/rails/issues/24279 Problem: By doing `record.errors.include? :foo`, it adds a new key to the @messages hash that defaults to an empty array. This happens because of a combination of these 2 commits: https://github.com/rails/rails/commit/b97035df64f5b2f912425c4a7fcb6e6bb3ddab8d (Added in Rails 4.1) and https://github.com/rails/rails/commit/6ec8ba16d85d5feaccb993c9756c1edcbbf0ba13#diff-fdcf8b65b5fb954372c6fe1ddf284c78R76 (Rails 5.0) By adding the default proc that returns an array for non-existing keys, ruby adds that key to the hash. Solution: Change `#include?` to check with `has_key?` and then check if that value is `present?`. Add test case for ActiveModels::Errors#include?
* | Apply scale before precision when coercing floats to decimalSean Griffin2016-03-242-2/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since precision is always larger than scale, it can actually change rounding behavior. Given a precision of 5 and a scale of 3, when you apply the precision of 5 to `1.25047`, the result is `1.2505`, which when the scale is applied would be `1.251` instead of the expected `1.250`. This issue appears to only occur with floats, as scale doesn't apply to other numeric types, and the bigdecimal constructor actually ignores precision entirely when working with strings. There's no way we could handle this for the "unknown object which responds to `to_d`" case, as we can't assume an interface for applying the scale. Fixes #24235
* | Use Range#cover? for Date inclusion validatorojab2016-03-241-3/+4
| |
* | Add edge cases to Time/Date/DateTime inclusion validation testsojab2016-03-241-3/+17
|/
* revises the homepage URL in the gemspecs [ci skip]Xavier Noria2016-03-101-1/+1
| | | | References https://github.com/rails/homepage/issues/46.
* use same name to type objectyuuji.yaginuma2016-03-091-1/+1
| | | | Follow up to #24079
* Remove load_paths fileArthur Neves2016-02-271-2/+0
|
* Preparing for 5.0.0.beta3 releaseeileencodes2016-02-241-0/+5
| | | | Adds changelog headers for beta3 release
* Prep release for Rails 5 beta3eileencodes2016-02-241-1/+1
|
* Revert changes to validations from PR #18612eileencodes2016-02-231-11/+0
| | | | | | | | | | | | | | | | | | | | In order to fix issue #17621 we added a check to validations that determined if a record should be validated. Based on the existing tests and behavior we wanted we determined the best way to do that was by checking if `!record.peristed? || record.changed? || record.marked_for_destruction?` This change didn't make it into a release until now. When #23790 was opened we realized that `valid?` and `invalid?` were broken and did not work on persisted records because of the `!record.persisted?`. While there is still a bug that #17621 brought up, this change was too drastic and should not be a RC blocker. I will work on fixing this so that we don't break `valid?` but also aren't validating parent records through child records if that parent record is validate false. This change removes the code changes to validate and the corresponding tests. It adds tests for two of the bugs found since Rails 5 beta2 release. Fixes #17621
* remove args from assert_nothing_raised in testsTara Scherner de la Fuente2016-02-222-4/+4
|
* Merge pull request #23743 from maclover7/rm-unused-parameterSantiago Pastorino2016-02-211-2/+2
|\ | | | | Remove unused parameter from method
| * Remove unused parameter from methodJon Moss2016-02-171-2/+2
| | | | | | | | | | | | The `attribute` parameter is not used inside the `normalize_detail` method. This does not need to go through a deprecation cycle, since the method is private.
* | Always validate record if validating a virtual attributeeileencodes2016-02-201-0/+7
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes #23645 When you're using an `attr_accessor` for a record instead of an attribute in the database there's no way for the record to know if it has `changed?` unless you tell it `attribute_will_change!("attribute")`. The change made in 27aa4dd updated validations to check if a record was `changed?` or `marked_for_destruction?` or not `persisted?`. It did not take into account virtual attributes that do not affect the model's dirty status. The only way to fix this is to always validate the record if the attribute does not belong to the set of attributes the record expects (in `record.attributes`) because virtual attributes will not be in that hash. I think we should consider deprecating this particular behavior in the future and requiring that the user mark the record dirty by noting that the virtual attribute will change. Unfortunately this isn't easy because we have no way of knowing that you did the "right thing" in your application by marking it dirty and will get the deprecation warning even if you are doing the correct thing. For now this restores expected behavior when using a virtual attribute by always validating the record, as well as adds tests for this case. I was going to add the `!record.attributes.include?(attribute)` to the `should_validate?` method but `uniqueness` cannot validate a virtual attribute with nothing to hold on to the attribute. Because of this `should_validate?` was about to become a very messy method so I decided to split them up so we can handle it specifically for each case.
* Add documentation about method to describe how it works [ci skip]Mehmet Emin İNAÇ2016-02-041-0/+9
|
* Preparing for Rails 5.0.0.beta2Sean Griffin2016-02-012-1/+6
|
* Wrangle the asset build into something that sounds more generalMatthew Draper2016-02-011-0/+3
|
* Merge branch '5-0-beta-sec'Aaron Patterson2016-01-253-3/+4
|\ | | | | | | | | | | | | | | | | | | | | * 5-0-beta-sec: bumping version fix version update task to deal with .beta1.1 Eliminate instance level writers for class accessors allow :file to be outside rails root, but anything else must be inside the rails view directory Don't short-circuit reject_if proc stop caching mime types globally use secure string comparisons for basic auth username / password
| * bumping versionAaron Patterson2016-01-251-1/+1
| |
| * Eliminate instance level writers for class accessorsAaron Patterson2016-01-222-2/+3
| | | | | | | | | | | | | | | | | | Instance level writers can have an impact on how the Active Model / Record objects are saved. Specifically, they can be used to bypass validations. This is a problem if mass assignment protection is disabled and specific attributes are passed to the constructor. CVE-2016-0753
* | Refactor tz aware types, add support for PG rangesSean Griffin2016-01-081-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is an alternate implementation to #22875, that generalizes a lot of the logic that type decorators are going to need, in order to have them work with arrays, ranges, etc. The types have the ability to map over a value, with the default implementation being to just yield that given value. Array and Range give more appropriate definitions. This does not automatically make ranges time zone aware, as they need to be added to the `time_zone_aware` types config, but we could certainly make that change if we feel it is appropriate. I do think this would be a breaking change however, and should at least have a deprecation cycle. Closes #22875. /cc @matthewd
* | remove activemodel dependency on builderLachlan Sylvester2016-01-061-2/+0
| |
* | Move CHANGELOG entry to Active RecordRafael Mendonça França2016-01-051-5/+0
| | | | | | | | | | | | | | | | While the type definition is in Active Model the change of behavior will be only user facing in Active Record so better to put the entry in its changelog. [ci skip]