Commit Graph

729 Commits

Author SHA1 Message Date
José Valim
d4457dc32b Provide read_attribute_for_serialization as the API to serialize attributes. 2011-09-30 14:20:41 +02:00
Nicolás Hock Isaza
da914fa35c Fixing as_json method for ActiveRecord models.
When you've got an AR Model and you override the `as_json` method,
you should be able to add default options to the renderer, like this:

    class User < ActiveRecord::Base
      def as_json(options = {})
        super(options.merge(:except => [:password_digest]))
      end
    end

This was not possible before this commit. See the added test case.
2011-09-29 21:44:23 -05:00
Jon Leighton
a15424b92c Make serializable_hash take attr values directly from attributes hash.
Previously, it would use send() to get the attribute. In Active
Resource, this would rely on hitting method missing. If a method with
the same name was defined further up the ancestor chain, that method
would wrongly be called.

This change fixes test_to_xml_with_private_method_name_as_attribute in
activeresource/test/cases/base_test.rb, which was broken after
51bef9d8fb, because that change made
to_xml use serializable_hash.
2011-09-26 12:40:03 +01:00
José Valim
4bfbdc133a Refactor AMo as_json. 2011-09-23 00:19:46 +02:00
Matt Aimonetti
6e78bbea90 fixed a bug with the json serialization when the class setting is set to not include the root, but an instance is serialized with the root option passed as true 2011-09-22 14:05:25 -07:00
José Valim
51bef9d8fb to_xml should also rely on serializable hash. 2011-09-18 09:09:01 -07:00
Vijay Dev
823e16f57c update 3.1 release date in changelogs 2011-09-14 22:46:12 +05:30
Jon Leighton
778c82bea6 Generate attribute method unless it's already in the module.
There's no harm in generating a method name that's already defined on
the host class, since we're generating the attribute methods in a module
that gets included. In fact, this is desirable as it allows the host
class to call super.
2011-09-14 00:00:37 +01:00
Jon Leighton
c89e1c7bde Add an attribute_missing method to ActiveModel::AttributeMethods.
This can be overloaded by implementors if necessary.
2011-09-13 00:02:33 +01:00
Jon Leighton
6d8dbeca6b Avoid double super call in some cases.
If super was false earlier, it is still going to be false, so we don't
need to call it again at the end of the method.
2011-09-13 00:01:58 +01:00
Jon Leighton
ac687ed651 Let Ruby deal with method visibility.
Check respond_to_without_attributes? in method_missing. If there is any
method that responds (even private), let super handle it and raise
NoMethodError if necessary.
2011-09-13 00:01:58 +01:00
Jon Leighton
99bd6b53da Add deprecation for doing attribute_method_suffix '' 2011-09-13 00:01:57 +01:00
Jon Leighton
93d574c962 refactoring 2011-09-13 00:01:57 +01:00
Jon Leighton
8b8b7143ef Use an empty AttributeMethodMatcher by default.
This means that attribute methods which don't exist will get generated
when define_attribute_methods is called, so we don't have to use hacks
like `attribute_method_suffix ''`.
2011-09-13 00:01:57 +01:00
Lawrence Pit
8817796167 Added test for obj.errors.as_json 2011-09-09 18:34:13 +10:00
Lawrence Pit
f5a944f662 Add ability to get an individual full error message + test for full_messages. 2011-09-09 18:28:25 +10:00
Damien Mathieu
e0335e2ccb add has_key? to ActiveModel::Errors 2011-09-06 18:36:18 +02:00
Guillermo Iguaran
9b02f3f41f Add comments about bcrypt-ruby gem to SecurePassword 2011-09-03 00:44:33 -05:00
Vijay Dev
eeda8403fd Merge branch 'master' of github.com:lifo/docrails 2011-09-02 23:00:59 +05:30
Guillermo Iguaran
6779064437 Remove hard dependency on bcrypt. 2011-09-02 10:01:47 -07:00
Josh Nesbitt
d0f9f4e664 Fix typo in ActiveModel::Dirty comment. define_attribute_methods is a class method, not attribute. 2011-09-02 13:28:38 +01:00
José Valim
d15069316f Merge pull request #2563 from bogdan/internal_validation
Implemented strict validation concept
2011-08-25 07:10:16 -07:00
Bogdan Gusiev
cbb147931b Typo fix 2011-08-25 16:43:43 +03:00
Aaron Patterson
09e2109686 bumping bcrypt-ruby requirement 2011-08-24 13:26:38 -07:00
Bogdan Gusiev
afe04da10b Add change log entry on strict validation 2011-08-24 10:26:18 +03:00
Xavier Noria
45f8ca54c9 Merge pull request #2653 from luckydev/ser-wrap
Missing require array/wrap in serialization
2011-08-23 04:05:34 -07:00
Anand
1be3442a0a added missing require array/wrap in serialization 2011-08-23 16:30:02 +05:30
Anand
56e32ad40f added more tests for only-include and except-include options in serialization 2011-08-23 16:03:58 +05:30
Bogdan Gusiev
8620bf90c5 Implemented strict validation concept
In order to deliver debug information to dev team
instead of display error message to end user
Implemented strict validation concept
that suppose to define validation that always raise exception when fails
2011-08-17 17:26:00 +03:00
Xavier Noria
0245792c83 Merge branch 'master' of github.com:lifo/docrails 2011-08-16 11:06:40 -07:00
Vijay Dev
b98d3ab6f5 fix misleading comment (originally made by Tate Johnson, we lost this commit while porting to the rails repo) 2011-08-14 19:29:35 +05:30
Xavier Noria
bf2b9d2de3 Merge branch 'master' of github.com:lifo/docrails
Conflicts:
	RELEASING_RAILS.rdoc
	actionpack/lib/sprockets/railtie.rb
	actionpack/test/template/sprockets_helper_test.rb
	activerecord/test/cases/calculations_test.rb
	railties/guides/source/3_1_release_notes.textile
	railties/guides/source/active_resource_basics.textile
	railties/guides/source/command_line.textile
2011-08-13 16:30:07 -07:00
Tate Johnson
239e615316 Fixed typo 2011-08-13 16:22:33 -07:00
Waynn Lue
2579d88405 capitalize RubyGems properl 2011-08-13 16:22:31 -07:00
Bogdan Gusiev
f86f770250 MassAssignmentProtection: consider 'id' insensetive in StrictSanitizer
In order to use StrictSanitizer in test mode
Consider :id as not sensetive attribute that can be filtered from
mass assignement without exception.
2011-08-13 16:22:26 -07:00
José Valim
b6b6e81a5c Rename new method to_path to to_partial_path to avoid conflicts with File#to_path and similar. 2011-08-13 16:22:26 -07:00
Grant Hutchins
c4cf9073a1 Give attribution to Peter Jaros for the patch we paired on. 2011-08-13 16:22:23 -07:00
José Valim
66fdfbc2d5 Update CHANGELOG. 2011-08-13 16:22:21 -07:00
José Valim
91ca214ca0 Rename class method to_path to _to_path and make it explicit that it is an internal method. 2011-08-13 16:22:21 -07:00
Grant Hutchins & Peter Jaros
6e671a8536 Let ActiveModel instances define partial paths.
Deprecate ActiveModel::Name#partial_path. Now you
should call #to_path directly on ActiveModel
instances.
2011-08-13 16:22:21 -07:00
thedarkone
45f9c2b361 Handle the empty array correctly. 2011-08-13 16:22:20 -07:00
Rashmi Yadav
111347f0cc The trailing '/' isn't being picked up by Github anyway, and the link works as is. 2011-08-13 16:22:15 -07:00
Myron Marston
d3c15a1d31 Allow ActiveRecord observers to be disabled.
We have to use Observer#update rather than Observer#send since the enabled state is checked in #update before forwarding the method call on.
2011-08-12 20:48:44 -07:00
Rashmi Yadav
681d919e48 The trailing '/' isn't being picked up by Github anyway, and the link works as is. 2011-08-04 16:41:31 -07:00
José Valim
6b3af028ac Merge pull request #2385 from bogdan/test_default_sanitizer2
MassAssignmentProtection: consider 'id' insensetive in StrictSanitizer
2011-08-01 04:50:06 -07:00
José Valim
dc8773b19f Rename new method to_path to to_partial_path to avoid conflicts with File#to_path and similar. 2011-08-01 11:42:00 +02:00
Grant Hutchins
b407034c9d Give attribution to Peter Jaros for the patch we paired on. 2011-07-28 13:38:28 -03:00
Bogdan Gusiev
b93a918337 MassAssignmentProtection: consider 'id' insensetive in StrictSanitizer
In order to use StrictSanitizer in test mode
Consider :id as not sensetive attribute that can be filtered from
mass assignement without exception.
2011-07-28 11:56:08 +03:00
José Valim
30dae273c8 Update CHANGELOG. 2011-07-28 10:05:17 +02:00
José Valim
dee8115539 Rename class method to_path to _to_path and make it explicit that it is an internal method. 2011-07-28 09:56:42 +02:00