Commit Graph

322 Commits

Author SHA1 Message Date
Carlos Antonio da Silva
10c3304db6 Make sure serializable hash with :include always returns string keys 2012-03-09 21:51:12 -03:00
Carlos Antonio da Silva
cb9d03f0d4 Add docs with usage examples for ActiveModel::Model
Also add test to ensure basic model does not explode when
initialized with nil.
2012-03-03 04:45:30 -03:00
Guillermo Iguaran
3b822e91d1 Add ActiveModel::Model, a mixin to make Ruby objects to work with AP inmediatly 2012-03-02 23:59:55 -05:00
Bogdan Gusiev
534dc4ca1a AM::Errors: allow :full_messages parameter for #as_json 2012-02-20 11:17:11 +02:00
Fabio Yamate
d204918f91 Fix sanitize_for_mass_assigment when role is nil
There is an example in Rails documentation that suggests implementing
assign_attributes method for ActiveModel interface, that by default
sends option role with nil. Since mass_assignment_authorizer never
is called without args, we can move the default value internally.
2012-02-15 11:13:54 -02:00
Carlos Antonio da Silva
ad9f968c4a Make sure serializable hash with :methods option returns always string keys 2012-02-13 11:22:59 -02:00
Carlos Antonio da Silva
5bcb4e3c18 Cleanup extra spaces 2012-02-13 11:20:19 -02:00
prasath
848ee296ec test title changed corresponding to the test 2012-02-09 02:11:36 +05:30
Aaron Patterson
06b9c905a9 Merge pull request #4930 from ask4prasath/ordered_hash_replaced
Replacing ordered hash to ruby hash on active model
2012-02-08 08:59:00 -08:00
José Valim
a17d047a73 Trim down Active Model API by removing valid? and errors.full_messages 2012-02-07 23:10:43 +01:00
prasath
47628ec128 replacing ordered hash to ruby hash 2012-02-08 00:34:47 +05:30
Niels Ganser
60dad828ae To infinity… and beyond!
Allow infinite values for validates_length_of. Particularly useful
for prettily defining an open ended range such as

validates_length_of :human_stupidity, :within => 0..Float::INFINITY
2012-02-06 12:58:32 +01:00
Carlos Antonio da Silva
26861e9506 Generate strict validation error messages with attribute name 2012-02-01 11:34:17 -02:00
prasath
f4d9ba0296 Removed unwanted intializer and replaced with ruby default collect method 2012-01-27 00:13:46 +05:30
prasath
bf31d7b224 Removing unwanted method and adding to accessor for getter history 2012-01-25 01:34:04 +05:30
dreamfall
e84998cc21 validates method should not change options argument 2012-01-17 13:18:58 +03:00
Paweł Kondzior
5313eab695 Fix ActiveModel::Errors#dup
Since ActiveModel::Errors instance keeps all error messages as hash
we should duplicate this object as well.

Previously ActiveModel::Errors was a subclass of ActiveSupport::OrderedHash,
which results in different behavior on `dup`, this may result in regression for
people relying on it.
2012-01-16 23:22:51 -08:00
Piotr Sarnacki
8e8982cf3b Add ActiveModel::Errors#delete, which was not available after move to use delegation 2012-01-16 17:23:40 +01:00
Carlos Antonio da Silva
e5df4f9255 Fix test class name that should read Without 2012-01-16 00:00:57 +01:00
Piotr Sarnacki
b164e81c11 Fix stack level too deep when model does not have attributes method.
Without that patch when using ActiveModel::AttributeMethods
in a class that does not respond to `attributes` method,
stack level too deep error will be raised on non existing
method. While documentation is clear that you need to define
`attributes` method in order to use AttributeMethods module,
`stack level too deep` is rather obscure and hard to debug,
therefore we should try to not break `method_missing` if
someone forgets about defining `attributes`.
2012-01-15 15:54:59 +01:00
Aaron Patterson
fec6f1ba82 Merge pull request #4360 from rafaelfranca/patch-1
Remove more references to Test::Unit
2012-01-06 16:43:18 -08:00
Aaron Patterson
b15d2c0708 require minitest rather than test/unit 2012-01-06 15:50:47 -08:00
Rafael Mendonça França
3d4754f131 Use ActiveModel::TestCase instead of Test::Unit:TestCase 2012-01-06 20:43:08 -03:00
Jon Leighton
93c1f11c0a Support configuration on ActiveRecord::Model.
The problem: We need to be able to specify configuration in a way that
can be inherited to models that include ActiveRecord::Model. So it is
no longer sufficient to put 'top level' config on ActiveRecord::Base,
but we do want configuration specified on ActiveRecord::Base and
descendants to continue to work.

So we need something like class_attribute that can be defined on a
module but that is inherited when ActiveRecord::Model is included.

The solution: added ActiveModel::Configuration module which provides a
config_attribute macro. It's a bit specific hence I am not putting this
in Active Support or making it a 'public API' at present.
2011-12-28 18:27:41 +00:00
Sergey Nartimov
9813c62330 remove deprecated define_attr_method from ActiveModel::AttributeMethods 2011-12-24 21:26:15 +03:00
Karunakar (Ruby)
ed1b4ea3f9 Changed the require path for logger 2011-12-21 19:42:44 +05:30
Karunakar (Ruby)
f7d3db71fc removed deprecated loggers 2011-12-21 19:30:45 +05:30
Jakub Kuźma
0fe311a7fc added :other_than => :!= option to numericality validator 2011-12-21 10:54:44 +01:00
José Valim
7ba28d434c Remove dead code from AMo. 2011-12-20 18:38:20 +01:00
Arun Agrawal
4fac64b1cc Fixed test "ArgumentError: wrong number of arguments(1 for 0)" 2011-12-17 16:49:01 +05:30
Antonio Roberto
66e747b461 Fixed bug when error message is an empty string. 2011-12-16 17:17:14 -02:00
José Valim
7280787a53 Improve cache on route_key lookup. 2011-12-08 19:53:16 +01:00
Marc-Andre Lafortune
d834755dad ActiveModel::Name#i18n_key: Fix doc and add tests 2011-12-05 22:02:53 -05:00
José Valim
d4964b3386 Namespaced attribute lookup now works as 'model/association.attribute'. 2011-12-05 15:39:41 +01:00
José Valim
2985151000 Merge pull request #3859 from kuroda/human_attribute_name
Fix human_attribute_name to handle names with dots
2011-12-05 06:09:33 -08:00
Tsutomu Kuroda
dff19f7be2 Fix human_attribute_name to handle names with dots
Nested I18n namespace lookup under activerecord.models is deprecated now (c19bd4f).
But when a model uses accepts_nested_attributes_for, its Errors object can have
an attribute name with "addresses.street" style. In this case, the dots should be
substituted with slashes so that we can provide the translation under the
"activemodel.attributes.person.addresses/street" key.
2011-12-05 22:57:47 +09:00
José Valim
5b2eb64ceb Revert "Implement ArraySerializer and move old serialization API to a new namespace."
This reverts commit 8896b4fdc8a543157cdf4dfc378607ebf6c10ab0.

Conflicts:

	activemodel/lib/active_model.rb
	activemodel/lib/active_model/serializable.rb
	activemodel/lib/active_model/serializer.rb
	activemodel/test/cases/serializer_test.rb
2011-11-30 18:48:17 +01:00
lest
6ce924fa9f fix method redefined warning in activemodel 2011-11-30 18:57:17 +03:00
Jon Leighton
8df787d428 Deprecated define_attr_method in ActiveModel::AttributeMethods
This only existed to support methods like `set_table_name` in Active
Record, which are themselves being deprecated.
2011-11-29 20:13:37 +00:00
Arun Agrawal
9817a8b7d6 Warning removed unused variable 2011-11-26 19:30:11 +05:30
José Valim
0a4035b12a Revert the serializers API as other alternatives are now also under discussion 2011-11-25 19:29:39 +00:00
José Valim
fcacc6986a Merge branch 'serializers'
This implements the ActiveModel::Serializer object. Includes code, tests, generators and guides.

From José and Yehuda with love.

Conflicts:
	railties/CHANGELOG.md
2011-11-25 09:59:35 +00:00
Jakub Kuźma
dc39af0a9a make ActiveModel::Name fail gracefully with anonymous classes 2011-11-24 15:50:21 +01:00
José Valim
28bcda4098 Rename UserSerializer to DefaultUserSerializer in tests. 2011-11-23 23:53:20 +00:00
José Valim
7fcc8c0a1f Rely solely on active_model_serializer and remove the fancy constant lookup. 2011-11-23 23:45:27 +00:00
José Valim
8896b4fdc8 Implement ArraySerializer and move old serialization API to a new namespace.
The following constants were renamed:

  ActiveModel::Serialization     => ActiveModel::Serializable
  ActiveModel::Serializers::JSON => ActiveModel::Serializable::JSON
  ActiveModel::Serializers::Xml  => ActiveModel::Serializable::XML

The main motivation for such a change is that `ActiveModel::Serializers::JSON`
was not actually a serializer, but a module that when included allows the target to be serializable to JSON.

With such changes, we were able to clean up the namespace to add true serializers as the ArraySerializer.
2011-11-23 23:18:15 +00:00
José Valim
e62de52aa3 Merge branch 'master' into serializers 2011-11-23 20:43:06 +00:00
José Valim
fd86a1b6b0 Rely on a public contract between railties instead of accessing railtie methods directly. 2011-11-23 19:06:45 +00:00
Prem Sichanugrist
0e2156d334 Update variable's name in the test case to reflect the class we're testing 2011-11-18 11:51:05 -05:00
Jon Leighton
f140445b1d Revert "Merge pull request #2378 from cesario/remove_warnings_activemodel"
This reverts commit 6aaae3de277b572f37e09f16ae12737c3c87dfb7, reversing
changes made to fdbc4e5f4e5746ebf558485348c841b33f038fda.

Reason: build failure.
2011-11-05 17:21:58 +00:00