Commit Graph

904 Commits

Author SHA1 Message Date
Bogdan Gusiev 46ec75661d Fixed AM::MasAsSec.attr_protected usage example.
Problems with current example:

* DOESN'T WORK 
** attr_protected :last_login, :as => :admin # doesn't make it accessible for admin
* Uses ActiveSupport Fixnum extension
2011-12-22 10:57:06 +02:00
Bogdan Gusiev 24a6609ea3 Fix AM::MassAssignementSecurity doc 2011-12-22 10:24:20 +02: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
Rahul P. Chaudhari e883c06a4f Updated gemspec for ruby 1.9.3 2011-12-21 11:09:01 +05:30
José Valim 7ba28d434c Remove dead code from AMo. 2011-12-20 18:38:20 +01:00
David Heinemeier Hansson 632fa15fa4 rails/master is now 4.0.0.beta and will only support Ruby 1.9.3+ 2011-12-20 09:30:37 -06:00
José Valim 23f6cabff1 Remove i18n dependencies from AP and AMo since they are in AS. 2011-12-20 08:51:56 +01:00
David Heinemeier Hansson 9d6e52b55e Party like its R-C-UNO! 2011-12-19 18:34:57 -06: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
José Valim f0f0e59c10 Ensure length validator also works on 1.8.7. 2011-12-06 14:13:44 +01:00
José Valim 81fec5dfc4 Merge pull request #3872 from marcandre/i18n_key
ActiveModel::Name#i18n_key: Fix doc and add tests
2011-12-06 00:41:43 -08:00
José Valim 1ee832b2d8 Merge pull request #3873 from iangreenleaf/no_default_tokenizer
Don't tokenize string when counting characters
2011-12-06 00:41:05 -08: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
Ian Young 5ff71ac9f8 Don't tokenize string when counting characters 2011-12-04 23:20:54 -08:00
Alexey Vakhov 814a4c3160 Fix argument error message for length validation 2011-12-01 09:12:16 +04:00
Vijay Dev 88daf08258 Merge branch 'master' of github.com:lifo/docrails 2011-11-30 23:32:01 +05:30
José Valim 5b2eb64ceb Revert "Implement ArraySerializer and move old serialization API to a new namespace."
This reverts commit 8896b4fdc8.

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
José Valim 38ab982cff Log 'Filter chain halted as CALLBACKNAME rendered or redirected' every time a before callback halts. 2011-11-30 09:53:09 +01: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
Alexey Vakhov 448df2d100 Cosmetic fixes in AM validatations docs 2011-11-27 10:23:40 +04:00
Arun Agrawal 9817a8b7d6 Warning removed unused variable 2011-11-26 19:30:11 +05:30
Vijay Dev 1d89540686 Merge branch 'master' of github.com:lifo/docrails 2011-11-26 19:14:39 +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
José Valim 696d01f7f4 Add docs to serializers. Update CHANGELOGs. 2011-11-25 09:49:54 +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
Alexey Vakhov efbb73562d Small docs fix in Active Model callbacks module 2011-11-19 12:19:59 +06: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
José Valim 9fa329b754 Speed up attribute invocation by checking if both name and calls are compilable. 2011-11-14 20:12:17 +01:00
Oscar Del Ben af64ac4e5c use any? instead of !empty? 2011-11-14 16:56:05 +01:00
Jean Boussier fd17ffc7a2 Fix a tiny typo in custom validators documentation 2011-11-10 18:49:37 +01:00
Anand 4cef581fcf replaced remove and define method calls to :redefine 2011-11-07 16:22:30 +05:30
Jon Leighton f140445b1d Revert "Merge pull request #2378 from cesario/remove_warnings_activemodel"
This reverts commit 6aaae3de27, reversing
changes made to fdbc4e5f4e.

Reason: build failure.
2011-11-05 17:21:58 +00:00
Vijay Dev 6aaae3de27 Merge pull request #2378 from cesario/remove_warnings_activemodel
Remove warnings by calling remove_method
2011-11-05 08:44:16 -07:00
Franck Verrot 1679aa56f3 Synchronize the gemspecs since CHANGELOG has been renamed to CHANGELOG.md 2011-11-04 14:46:39 +01:00
Jon Leighton 281272ad36 Convert CHANGELOGs to Markdown format.
Reasons:

 * Markdown reads well as plain text, but can also be formatted.
 * It will make it easier for people to read on the web as Github
   formats the Markdown nicely.
 * It will encourage a level of consistency when people are writing
   CHANGELOG entries.

The script used to perform the conversion is at
https://gist.github.com/1339263
2011-11-04 12:55:17 +00:00
bradrobertson 2e62af310d correct documentation on initialize method to accept a single parameter 2011-10-26 09:31:37 -04:00
Vijay Dev af1b5c54cf Merge branch 'master' of github.com:lifo/docrails 2011-10-20 23:20:44 +05:30
Martin Svalin 930dc335d7 Removed mention of deprecated ActiveModel::Errors#on 2011-10-19 23:13:15 +02:00
Martin Svalin c9ca86c29d New #added? method on ActiveModel::Errors
The #added? method makes it possible to check if a specific error has been added, using the same parameters as for #add.
2011-10-19 21:29:20 +02:00
Vijay Dev 8dffc62a9b use variables from test setup 2011-10-17 19:15:24 +05:30
Vijay Dev 826a850696 fix a typo and slightly reword has_secure_password comment 2011-10-17 19:14:29 +05:30
Martin Svalin 180d4137ca ActiveModel::Errors#generate_message without i18n_scope, and more test cases for #add 2011-10-17 09:22:08 +02:00
Jose and Yehuda afd7140b66 Remove 1.9 Hash syntax - tests passing on 1.8.7 2011-10-15 22:33:58 +02:00
Jose and Yehuda 2abb2e617a Add initial support for embed API 2011-10-15 19:22:16 +02:00
Jose and Yehuda a230f040ff Add support for the root attribute 2011-10-15 18:56:47 +02:00
Jose and Yehuda 7a28498b55 Fix nil has_one association 2011-10-15 18:40:38 +02:00
Jose and Yehuda 322f47898e Add association_ids 2011-10-15 18:40:38 +02:00
Jose and Yehuda 22c322f056 Add support for overriding associations, mostly used for authorization 2011-10-15 18:40:38 +02:00
Jose and Yehuda 776da539d7 Add support for implicit serializers 2011-10-15 18:40:38 +02:00
Jose and Yehuda 2a4aaae72a Added has_one and has_many 2011-10-15 18:40:37 +02:00
Jose and Yehuda e407dfb9bf Don't require serializable_hash to take options. 2011-10-15 18:40:37 +02:00
Jose and Yehuda c3de52d7ed Initial implementation of ActiveModel::Serializer 2011-10-15 18:40:37 +02:00
Vijay Dev e759c8882a Merge branch 'master' of github.com:lifo/docrails 2011-10-14 22:21:40 +05:30
zhengjia 1adf5662b5 Fixed serialization issues with multiple includes with options 2011-10-11 11:09:43 -05:00
Evgeniy Dolzhenko c317419359 Use .add instead of << to add errors 2011-10-11 14:13:08 +01:00
Uģis Ozols 4015080efd One of the activemodel naming tests wasn't asserting anything. 2011-10-07 16:42:44 +03:00
Vijay Dev 46ce7f1f77 Merge branch 'master' of github.com:lifo/docrails 2011-10-05 18:42:18 +05:30
Robert Ross ac49fb1aa9 Change one more place for JSON string to Hash 2011-10-04 23:42:37 -07:00
Robert Ross eef176dc7d Fix as_json doc to say what it actually returns. 2011-10-04 09:37:54 -07:00
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
Uģis Ozols 62a9e5a960 Class name specified in example is Person, not AttributePerson. 2011-09-29 14:33:32 +03: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
Franck Verrot 325fdfc928 Remove warnings by calling remove_method 2011-07-31 20:05:58 +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
José Valim 1b7db58a06 Merge pull request #2034 from Casecommons/to_path
Allow ActiveModel-compatible instances to define their own partial paths
2011-07-28 00:50:07 -07:00
Santiago Pastorino fa2bfd832c Merge pull request #2305 from thedarkone/errors-include
Improve AM::Errors#include?
2011-07-27 09:44:15 -07:00
thedarkone efe4cbe5f2 Handle the empty array correctly. 2011-07-27 18:07:47 +02:00
Grant Hutchins & Peter Jaros bf812074fd Let ActiveModel instances define partial paths.
Deprecate ActiveModel::Name#partial_path. Now you
should call #to_path directly on ActiveModel
instances.
2011-07-25 16:05:24 -04:00
Ben Marini c02288e6fd Fix example code for #validates_with instance method 2011-07-24 12:13:23 -07:00
Xavier Noria ace3723d2f Merge branch 'master' of git://github.com/lifo/docrails 2011-07-23 12:15:41 +02:00
Vishnu Atrai 5801f42975 fixed type 2011-07-21 10:12:29 -07:00
Bratish Goswami 840ca47a46 Download and installation, License and Support sections added for activemodel 2011-07-21 13:03:45 +05:30
Sebastian Gassner 9714d866f5 Documentation fix: adding missing equal sign in code sample for ActiveModel::Dirty. 2011-07-20 10:31:57 +02:00
José Valim da144894e9 Merge pull request #195 from bigfix/active_model_include_serialization
ActiveModel support for the :include serialization option
2011-07-18 06:50:43 -07:00
John Firebaugh 4860143ee4 ActiveModel support for the :include serialization option
This commit moves support for the :include serialization option for
serializing associated objects out of ActiveRecord in into ActiveModel.
The following methods support the :include option:

  * serializable_hash
  * to_json
  * to_xml

Instances must respond to methods named by the values of the :includes
array (or keys of the :includes hash). If an association method returns
an object that is_a?(Enumerable) (which AR has_many associations do), it
is assumed to be a collection association, and its elements must respond
to :serializable_hash. Otherwise it must respond to :serializable_hash
itself.

While here, fix #858, XmlSerializer should not singularize already
singular association names.
2011-07-17 11:34:07 -07:00
John Firebaugh cbf924ef08 Replace map+compact with select 2011-07-17 11:34:06 -07:00
John Firebaugh 2a9a10f5e3 Add a test 2011-07-17 11:34:06 -07:00
John Firebaugh da4e1faf6f serializable_hash(:only => [], :methods => [:foo]) should work 2011-07-17 11:34:06 -07:00
Lawrence Pit 52a096275a Made attribute_method_matchers_cache private + doc 2011-07-17 14:51:34 +10:00
Lawrence Pit c3dd4c653d Issue #2075 Optimization of ActiveModel's match_attribute_method? 2011-07-16 16:40:11 +10:00
Lawrence Pit f04c5d640d Optimization of ActiveModel's match_attribute_method? 2011-07-15 09:58:46 +10:00
Joe Fiorini ac5e691153 Enable passing root: false to #to_json 2011-07-01 23:00:13 -04:00
Santiago Pastorino 35cdd256c0 Master version is 3.2.0.beta 2011-06-30 10:18:36 -03:00
Ian Stewart eafa174bfd changing an attribute multiple times retains the correct original value 2011-06-28 22:18:24 -07:00
Alexander Uvarov e945497955 Minor formating fix 2011-06-24 03:52:39 +06:00
Alexander Uvarov ee044ea547 Follow rails convention by using Array.wrap 2011-06-23 23:06:52 +06:00
Alexander Uvarov 528f405cdc Allow to specify mass-assignment roles as array 2011-06-23 12:56:39 +06:00
Xavier Noria 146ec2d1df Merge branch 'master' of git://github.com/lifo/docrails 2011-06-18 10:11:47 +02:00
Santiago Pastorino 5599e3fa0c Merge pull request #1654 from ganeshkumar/test_cases
removed duplicate code in tests
2011-06-13 05:45:47 -07:00