Commit Graph

622 Commits

Author SHA1 Message Date
Carl Lerche
cd13fbd8d8 Optionally pass in the attribute being validated to an instance method validator 2011-02-05 16:44:35 -08:00
Carl Lerche
e9e9ed6b60 Be able to pass a validator method to #validates 2011-02-05 16:33:00 -08:00
Carl Lerche
ed7614aa7d Provide a way to specify alternate option keys for validates 2011-02-05 16:00:57 -08:00
Carl Lerche
7176ade35b Do not require that validation attributes be specified as symbols 2011-02-05 15:37:38 -08:00
Santiago Pastorino
082326deb5 module_eval is not needed here 2011-02-03 20:47:02 -02:00
Santiago Pastorino
6f4d9989dd method_defined?, define_method and send accepts a string as argument 2011-02-03 20:37:12 -02:00
Caleb Land
bca070ef2d allow spaces and other characters in attribute names [#4725 state:resolved]
* define the dynamically defined methods with
  'define_method' instead of def
* wrap some string injected method names in quotes

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-02-03 19:05:17 -02:00
Xavier Noria
a96a9a4948 Merge branch 'master' of git://github.com/lifo/docrails 2011-02-02 22:04:11 +01:00
John Firebaugh
57bc25c5f8 Use run_callbacks; the generated _run_<name>_callbacks method is not a public interface.
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-01-31 19:45:53 -02:00
Paul Yoder
d8919d3151 Deleted extra "a" in method comment 2011-01-27 09:27:35 -06:00
Aaron Patterson
b5cc277763 psych does not emit a space after the tag 2011-01-21 15:13:30 -08:00
Xavier Noria
236f1f52cd Merge branch 'master' of git://github.com/lifo/docrails 2011-01-20 10:33:38 +01:00
Daniel Schierbeck
1a051259b4 Properly indent code example block 2011-01-15 17:54:02 +01:00
brainopia
da82b0a746 Remove reference to ActiveRecord from ActiveModel comments 2011-01-15 03:10:10 +03:00
Santiago Pastorino
9a57a2279e sorry, the CI cannot lie to us anymore (Part II) 2011-01-13 10:55:41 -02:00
Santiago Pastorino
2b2b50660b Bump up bcrypt-ruby dependency to 2.1.4 2011-01-09 19:04:43 -02:00
Hemant Kumar
8de5595e4d fix difference between behaviour of blank and empty
Signed-off-by: José Valim <jose.valim@gmail.com>
2011-01-05 13:18:10 +01:00
Xavier Noria
99424eb099 Revert "Update CHANGELOGs to include 3.0.3 changes"
Reason: Sorry, CHANGELOGs can only be edited in master.
If you provide a patch I'll apply it myself. Thanks!

This reverts commit 1f8ecb85d7c1b3efdf45c3cf3461502b608c1a7c.
2011-01-02 00:20:59 +01:00
Prem Sichanugrist
1f8ecb85d7 Update CHANGELOGs to include 3.0.3 changes 2011-01-02 03:35:38 +07:00
David Heinemeier Hansson
43433b3fb4 Instance methods shouldnt be added until you actually call has_secure_password 2010-12-29 10:18:14 -08:00
José Valim
6b099975fa No need to symbolize these. 2010-12-27 09:30:36 +01:00
Aaron Patterson
207f266cca define_attr_method must serialize nil correctly 2010-12-20 19:47:15 -08:00
Xavier Noria
880f8419c4 Merge branch 'master' of git://github.com/lifo/docrails 2010-12-20 20:13:34 +01:00
Santiago Pastorino
ab2bde45f8 Remove require AS::Concern from places where is already in 2010-12-19 19:15:26 -02:00
Santiago Pastorino
5fb42ac478 Tests and docs which explain the use of validate with a block and without arguments 2010-12-19 18:50:18 -02:00
Vijay Dev
4038a6bc0f minor fixesin READMEs 2010-12-20 01:07:33 +05:30
Santiago Pastorino
08ccd29b5b Remove weak_passwords list and the length/strong password validator, leave that up to the programmer 2010-12-19 15:01:29 -02:00
José Valim
6d80f3a1ba Use class_attribute to ensure weak_passwords are inheritable. 2010-12-19 13:31:48 +01:00
Mikel Lindsaar
6c217f98db Add set_weak_passwords call in alignment with set_table_name. 2010-12-19 21:36:47 +11:00
Mikel Lindsaar
fa14df08a8 Fix incorrect docs 2010-12-19 20:54:15 +11:00
Mikel Lindsaar
a39a333769 Added ability to specify which passwords you want as weak passwords 2010-12-19 20:39:54 +11:00
José Valim
863de37b05 'unsecure' => 'insecure' 2010-12-19 09:37:08 +01:00
José Valim
432556b923 Make password messages translatable. 2010-12-19 09:34:31 +01:00
José Valim
b8f6dd8cbb Add missing require and remove extra module. 2010-12-19 09:31:26 +01:00
José Valim
d592fa946d Avoid warnings and fix small typo on SecurePassword. 2010-12-19 09:28:15 +01:00
David Heinemeier Hansson
bd9dc4ff23 BCrypt does its own salting, lovely! 2010-12-18 19:09:07 -08:00
David Heinemeier Hansson
39b5ea6e01 Switch from SHA2 to BCrypt (easy Windows compatibility is coming shortly with new compiled gem) 2010-12-18 15:39:32 -08:00
David Heinemeier Hansson
bcf4e4f2b0 Added ActiveRecord::Base#has_secure_password (via ActiveModel::SecurePassword) to encapsulate dead-simple password usage with SHA2 encryption and salting 2010-12-18 13:38:05 -08:00
Akira Matsuda
a3fbbb626f 'nil' => nil 2010-12-17 14:37:22 +09:00
Santiago Pastorino
9cfbada93a This is not an executable file 2010-12-16 01:49:28 +05:30
Samuel Kadolph
972011a2e5 Add support for namespaced validators
Includes test and documentation for new feature

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-12-16 01:49:28 +05:30
Santiago Pastorino
32a2bf8d4e This is not an executable file 2010-12-11 16:40:05 -02:00
Samuel Kadolph
2650742bd0 Add support for namespaced validators
Includes test and documentation for new feature

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-12-11 16:35:18 -02:00
Xavier Noria
c6612d2bb3 Merge branch 'master' of git://github.com/lifo/docrails
Conflicts:
	activerecord/lib/active_record/transactions.rb
2010-12-11 00:55:25 +01:00
Ryan Bigg
b4ec6f0d39 Move ActiveModel::Lint::Tests documentation to be above module declaration so it appears in the API docs for this module. 2010-12-09 18:16:18 +10:00
Mike Dvorkin
f572a02b94 Take into account current time zone when serializing datetime values [#6096 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-12-09 09:01:49 +01:00
Santiago Pastorino
7c920631ec Test using default option as symbol added for human_attribute_name 2010-12-05 13:26:14 -02:00
Santiago Pastorino
33b0a30fcc default could be a symbol here so attribute.to_s.humanize should be the final option 2010-12-05 12:57:45 -02:00
Santiago Pastorino
3ab98cf6e0 If default is provided don't add attribute.to_s.humanize to the options 2010-12-05 12:36:56 -02:00
Santiago Pastorino
0dbf4ac709 Test falling back to default added for human_attribute_name 2010-12-05 12:36:53 -02:00
Santiago Pastorino
b870d67290 Test using default option added for human_attribute_name 2010-12-05 12:36:51 -02:00
Xavier Noria
48386d245b Merge branch 'master' of git://github.com/lifo/docrails 2010-12-05 10:33:50 +01:00
Sven Fuchs
7ffd5daa7f bump i18n gem
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-12-04 18:00:31 +01:00
Santiago Pastorino
acbabd9626 Don't compute this string again 2010-12-02 15:43:12 -02:00
Thilo Utke
7148b933c4 ActiveModel::Errors.to_hash returns plain OrderedHash and used in to_json serialization to properly handle multiple errors per attribute [#5615 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-12-01 11:43:37 +01:00
José Valim
1ec126dd37 Revert "Fix generation of wrong json string when field has multiple errors"
This reverts commit a9b666b51d28b2e74da630c31327dee7cbe96d37.
2010-12-01 11:42:30 +01:00
Krekoten' Marjan
a9b666b51d Fix generation of wrong json string when field has multiple errors 2010-12-01 00:03:42 +08:00
Aditya Sanghi
04922bafda grammar fix 2010-11-27 19:56:08 +05:30
raggi
cb1570936d Rakefiles are executables, and rake loads rake, not rakefile code 2010-11-25 06:49:55 +08:00
Aaron Patterson
938243feb9 do not require ruby-debug automatically. please require it if you have declared it as a dependency 2010-11-19 16:26:09 -08:00
Santiago Pastorino
884e3506d2 Bump builder to 3.0.0 2010-11-17 19:35:58 -02:00
Carl Lerche
ccd2f3ede5 Update the version.rb files to include a PRE part 2010-11-16 17:19:46 -08:00
Robert Pankowecki
88688cdd8e Fix when database column name has some symbolic characters. [#5818 state:resolved] 2010-11-14 17:24:31 +08:00
Xavier Noria
41366cdec6 syncs CHANGELOGs for 3.0.2 in 3-0-stable with the ones in master 2010-11-09 20:56:41 +01:00
Jeremy Holland
ea0faa2055 Allowing to_xml :camelize option to be set to :lower to enable lower-camelcase tags [#5903 state:resolved] 2010-11-03 10:43:45 -07:00
snusnu
973b908777 Added missing AS require to active_model/naming.rb
We saw a failing spec when running the DataMapper
ActiveModel compliance specs for dm-active_model.

  ActiveModel::Naming#model_name

relies on the Module#parents method defined in

  active_support/core_ext/module/introspection.rb

Adding the appropriate require statement of course
fixed our specs.
2010-10-30 00:20:31 +08:00
José Valim
2a90a4e51c Use latest I18n. 2010-10-26 18:17:11 -02:00
Santiago Pastorino
460c4efd71 Merge CHANGELOGs from 3-0-stable 2010-10-18 12:24:41 -02:00
wycats
cc8e386d08 Always pull in version for frameworks (standardize autoload / require / none) 2010-10-10 16:12:04 -07:00
Xavier Noria
db520042b3 Merge branch 'master' of git://github.com/lifo/docrails 2010-10-06 23:16:13 +02:00
José Valim
232e56ce87 No need to pass self as parameter here. 2010-10-04 22:32:29 +02:00
Ernie Miller
21cb1d40b9 Test to_model being called in ActiveModel::Naming helpers
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-10-04 21:26:42 +02:00
Ernie Miller
33aaa15f62 Convert to model before calling model_name on a record in ActiveModel::Naming
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-10-04 21:26:41 +02:00
fastred
4ea9a8d9ad Fix syntax error in ActiveModel::Validations .validate example 2010-10-01 18:32:46 +02:00
Neeraj Singh
72c1e19c33 after_create in ActiveModel should in the order specified
[#5650 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-27 23:11:31 +02:00
José Valim
fe0251e408 Merge remote branch 'miloops/warnings'
Conflicts:
	actionpack/lib/action_controller/metal/url_for.rb
2010-09-27 21:00:54 +02:00
thedarkone
9c57bd8578 Fix Namind#model_name. 2010-09-27 17:46:00 +02:00
Emilio Tagua
be9883b09d Don't redefine existing attributes accessors. 2010-09-27 11:19:19 -03:00
John Firebaugh
75a960ca6e Don't act destructively on ActiveModel::Name#human options hash. [#5366 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-25 10:59:54 +02:00
Rodrigo Rosenfeld Rosas
8d30193b08 Properly interpolate i18n keys in modules [#5572 state:resolved] 2010-09-24 20:41:12 +02:00
Obie Fernandez
275f922a23 Better shortcut options for custom validators [#5672 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-24 12:49:16 +02:00
Xavier Noria
8c0c815ba7 resolves rdoc conflict 2010-09-23 22:35:08 +02:00
Emilio Tagua
dc2f26ca38 Perf: refactor methods using inject when not need in activemodel.
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-09-22 18:08:03 -03:00
Neeraj Singh
8ae913664f remove irrelevant comments
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-18 20:33:40 +02:00
Alexey Mahotkin
dfebdb1b03 Tiny fixes to rdoc 2010-09-16 17:10:36 +04:00
Mikel Lindsaar
bca9b84a4a Fixing documentation to reflect deprecated add_to_base 2010-09-12 14:19:38 +10:00
Jeremy Kemper
d79b1aa0ba Fewer object allocations 2010-09-09 14:37:58 -07:00
Jeremy Kemper
cb67d16629 Cheaper attribute_method_matchers 2010-09-09 14:37:58 -07:00
Jeremy Kemper
82ea5db030 Fix require for class_attribute 2010-09-09 14:34:29 -07:00
Jakub Suder
2524cf404c fixed some issues with JSON encoding
- as_json in ActiveModel should return a hash
  and handle :only/:except/:methods options
- Array and Hash should call as_json on their elements
- json methods should not modify options argument

[#5374 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-09-07 11:33:10 -07:00
Carlos Antonio da Silva
69a4c67a3f Fix docs related to param_key in ActiveModel::Naming
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-05 18:14:37 +02:00
Piotr Sarnacki
bf1ac82cec Add some documantation on new route_key and param_key in ActiveModel::Naming 2010-09-03 22:59:15 +02:00
Piotr Sarnacki
6e5aed057f Prepared ActiveModel::Naming to handle cases for namespaced isolated engines 2010-09-03 22:59:15 +02:00
José Valim
599e46bf24 Revert "Setup explicit requires for files with exceptions. Removed them from autoloading."
Booting a new Rails application does not work after this commit [#5359 state:open]

This reverts commit 38a421b34d0b414564e919f67d339fac067a56e6.
2010-09-02 21:11:03 +02:00
Andreas Garnæs
1503e45e2e ActiveModel#to_xml fix (renamed parameter).
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-02 12:55:45 +02:00
Łukasz Strzałkowski
38a421b34d Setup explicit requires for files with exceptions. Removed them from autoloading.
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-02 11:54:04 +02:00
Subba Rao Pasupuleti
0ae81a2124 Refactoring conditional logic
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-01 14:00:26 +02:00
Subba Rao Pasupuleti
2d74ed49f4 reader method eliminates defined? checks
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-09-01 13:59:53 +02:00
Neeraj Singh
8402488568 adding new test for ActiveModel::Serialization
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-08-31 17:45:03 +02:00
José Valim
d37a65307d Merge josevalim/deprecations branch.
I maintained on purpose the DeprecatedUrlOptions in ActionMailer and the Deprecated configuration in Railties because they were already addressed by Piotr in his RSoC work.
2010-08-30 15:55:10 -03:00
Jeremy Kemper
b861942691 Update CHANGELOGs for 3.0 release and upcoming 3.1 2010-08-29 22:06:48 -07:00
José Valim
f0ee4a6002 Remove deprecations in ActiveModel. 2010-08-29 20:45:34 -03:00
Xavier Noria
a302a333f8 revises a deprecation message 2010-08-29 22:47:18 +02:00
Jeremy Kemper
0d0c46abd1 Clean up CHANGELOGs 2010-08-28 15:45:14 -07:00
Jaime Iniesta
5430f5bd06 lifecycle should be two words, life cycle 2010-08-26 14:23:58 +02:00
James Miller
4b07bc8475 to_json => as_json 2010-08-25 15:23:21 -07:00
David Heinemeier Hansson
21b1f29720 Master is now targeting 3.1.0.beta 2010-08-23 21:44:57 -05:00
Santiago Pastorino
9992a1a4bf type fixed 2010-08-22 19:59:36 -03:00
Neeraj Singh
2ffa50f5a9 after_validation should be called irrespective of the result of validation.
I confirmed that this is the behavior on 2.3.x .

[5419 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-08-20 11:24:43 -03:00
Xavier Noria
43291469cb deletes the rdoc task of each component, they are no longer published separately 2010-08-20 13:30:31 +02:00
Santiago Pastorino
cad8bef5ea Bump up rdoc to 2.5.10 2010-08-18 11:44:12 -03:00
Xavier Noria
a0ca3d1067 Merge remote branch 'docrails/master' 2010-08-18 00:25:32 +02:00
Xavier Noria
ea2ad26a8d you rarely want ^ or $ in validations, use \A when you mean \A 2010-08-18 00:15:01 +02:00
Trey Bean
bee414748c Missing object for comparison in ActiveModel::EachValidator example code. 2010-08-17 12:51:13 -06:00
Xavier Noria
fb6b805620 code gardening: we have assert_(nil|blank|present), more concise, with better default failure messages - let's use them 2010-08-17 03:32:11 +02:00
José Valim
d0cf212cb5 to_key should return all exists keys (if any exists), regardless if the object is persisted or not. If you need it to reflect persistance, you should use to_param. 2010-08-15 11:29:15 -03:00
Subba Rao Pasupuleti
e516378410 Adding missing required statement
[#5056 state:resolved]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-08-14 13:17:32 +02:00
Santiago Pastorino
b95d6e84b0 Deletes trailing whitespaces (over text files only find * -type f -exec sed 's/[ \t]*$//' -i {} \;) 2010-08-14 13:17:32 +02:00
Subba Rao Pasupuleti
f8f437191f no callbacks should be created for empty array [#5289 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-08-14 13:17:30 +02:00
Subba Rao Pasupuleti
b61ff257e9 tidy up validations length code [#5297 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-08-14 13:17:29 +02:00
Greg Campbell
1577eafe77 Add missing ActiveModel::Validations require
[#5311 state: resolved]

ActiveModel::Validations uses Hash#except, but does not require it from
ActiveSupport.  (This wasn't showing up in the tests, because it was
required in the helper, and was also required in
ActiveModel::Serialization).

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-08-14 13:17:29 +02:00
Subba Rao Pasupuleti
b7fdc937fa Adding missing required statement
[#5056 state:resolved]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-08-14 06:27:15 -03:00
Santiago Pastorino
b451de0d6d Deletes trailing whitespaces (over text files only find * -type f -exec sed 's/[ \t]*$//' -i {} \;) 2010-08-14 04:12:33 -03:00
Subba Rao Pasupuleti
ef0da581e9 no callbacks should be created for empty array [#5289 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-08-12 13:12:26 -03:00
Subba Rao Pasupuleti
e82b38cd57 tidy up validations length code [#5297 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-08-12 13:12:03 -03:00
Greg Campbell
90a7915ab2 Add missing ActiveModel::Validations require
[#5311 state: resolved]

ActiveModel::Validations uses Hash#except, but does not require it from
ActiveSupport.  (This wasn't showing up in the tests, because it was
required in the helper, and was also required in
ActiveModel::Serialization).

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-08-12 13:11:48 -03:00
Xavier Noria
4134d7db34 Merge remote branch 'docrails/master' 2010-08-12 17:36:09 +02:00
Paco Guzman
8a2b69b727 applied guidelines to "# =>" 2010-08-12 17:09:58 +02:00
Santiago Pastorino
a6c6cbfb55 ActiveModel::Base doesn't exist, include_root_in_json is a class_attribute for the classes which includes this module 2010-08-10 11:53:58 -03:00
Xavier Noria
fff917e37d fixes a typo reported by rymai 2010-08-10 15:34:54 +02:00
Adam Meehan
9a43640ed1 typo in AM 2010-08-09 13:44:04 +10:00
Xavier Noria
3e678240f4 edit pass to AMo::Serializers::JSON 2010-08-06 13:56:38 +02:00
Xavier Noria
3cbe111439 Merge remote branch 'docrails/master' 2010-08-05 01:15:57 +02:00
Neeraj Singh
589e6977d7 adding documentation to ActiveSupport::Concern ht:strictly typed for an awesome example
some minor documentation changes
2010-08-04 17:03:03 -04:00
Subba Rao Pasupuleti
8d9d8bc93c Tidy up error.rb code
[#5288 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2010-08-03 14:54:13 -03:00
José Valim
84081fcc54 Freeze options so we raise an error when people modify it in place. 2010-08-03 15:36:23 +02:00
José Valim
f23bc8444b validates_length_of should not change the options hash in place. [#5283 state:resolved] 2010-08-03 15:22:54 +02:00
rohit
621246f997 Failing test for validates_length_of, when both too_short and too_long messages are set [#5283 state:open]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-08-03 15:11:51 +02:00
Tore Darell
2c8a4a53a8 Remove or fix non-working examples and add a few tests to Dirty [#5185 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-08-03 10:47:30 +02:00
Neeraj Singh
fb2b8fec24 adding test cases for ActiveModel::Errors
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-08-03 10:46:16 +02:00
Neeraj Singh
74f7e172c7 fixing documentation 2010-08-03 04:14:14 -04:00
Alex Le
aeaab06c79 ActiveModel::Errors json serialization to work as Rails 3b4 [#5254 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-08-02 16:26:32 +02:00
Xavier Noria
ccd45618ed Merge remote branch 'rails/master' 2010-07-30 02:35:24 +02:00
Xavier Noria
755af49755 edit pass to apply API guideline wrt the use of "# =>" in example code 2010-07-30 02:30:04 +02:00
Neeraj Singh
1a6d76223b expanding on the will_change! method in documentation 2010-07-29 09:18:29 -04:00
David Heinemeier Hansson
856fc4bbc3 Prep for RC 2010-07-26 12:53:25 -05:00
Xavier Noria
6aa1253588 Merge remote branch 'docrails/master' 2010-07-26 00:23:57 +02:00
Aaron Patterson
b50635a59f update Rakefiles for RDoc 2.5 2010-07-23 21:11:29 +02:00
Santiago Pastorino
b378b19430 Makes Rakefile activate rdoc >= 2.5.9
Signed-off-by: Xavier Noria <fxn@hashref.com>
2010-07-23 00:04:06 +02:00
Mislav Marohnić
3e196db6ad improve Active Model README
- fix indentation problems
 - revised introductory text to state right away what the library is
 - improved examples: reduce heavy usage of ellipsis,
   don't mark paragraphs of text as code
2010-07-22 10:03:55 +02:00