José Valim
90af9e0d16
Merge pull request #98 from ccschmitz/patch-1
...
Fix a couple typos
2012-07-16 08:19:27 -07:00
Chris Schmitz
a6473e70c4
Fix a couple typos.
2012-07-16 09:29:12 -05:00
twinturbo
6f3b250dc9
Don't include empty polymoprhic associations
...
Take this serializer:
class TodoSerializer < ActiveModel::Serializer
root :todo, :include => true
has_one :reference, :polymorphic => true
end
A nil reference would generate this JSON:
{
"todo": { "reference": null },
"nil_classes": []
}
This commit prevents the `nil_classes` key from being added when
serializing and including nil polymoprhic associations.
2012-07-16 15:08:01 +02:00
twinturbo
486d282922
Raise error when associations cannot be included
...
include! only works when the source serializer has a root set. The
as_json method sets up some state for the include! method. If a child
association has associations with `:include => true` or `root foo,
:include => true` would cause an undefined method error for `NilClass`.
This is entirely unhelpful for the end user.
This commit raise an error when this situation occurs. It makes it clear
that it's not a problem with AMS but the serialization graph.
2012-07-16 14:18:58 +02:00
twinturbo
5111615ac1
Actually test set serialization
2012-07-15 13:42:29 +02:00
José Valim
f2714ace8a
Merge pull request #96 from bradleypriest/fixbuild
...
Fix Travis on 1.8.7
2012-07-15 04:21:00 -07:00
Bradley Priest
f85c624d02
Fix travis
2012-07-15 18:50:47 +08:00
twinturbo
7072e79787
Close #90
2012-07-15 12:18:41 +02:00
José Valim
7d1568f2b8
Merge pull request #50 from twinturbo/polymorphism
...
Polymorphism
2012-07-15 03:18:33 -07:00
twinturbo
f01fe14972
Fix spelling mistakes
2012-07-15 11:49:36 +02:00
twinturbo
cbd7d7d385
Add test for nested included polymoprhic associations
2012-07-15 11:49:36 +02:00
twinturbo
c4e5cd547b
Add test for complex polymorphic associations
2012-07-15 11:49:36 +02:00
twinturbo
9f20fe8b36
Test passes
2012-07-15 11:49:36 +02:00
twinturbo
3ca1621011
Add failing test for polymorphic with include
2012-07-15 11:49:36 +02:00
twinturbo
7e96856b87
Support serialize polymorphic id
2012-07-15 11:49:36 +02:00
twinturbo
32f8779114
Basic rooted polymorphism
2012-07-15 11:49:36 +02:00
Tee Parham
84c7cfa988
fix test for custom serializer, add test for :each_serializer
2012-07-14 22:03:14 -06:00
Tee Parham
0832e42917
add class attribute :root to ArraySerializer
...
You can now set the default behavior for Array serialization in a
single place
2012-07-14 21:44:23 -06:00
José Valim
56824f055b
Update master
2012-07-14 18:17:36 +03:00
José Valim
565ad580b6
Merge pull request #93 from twinturbo/scoped
...
Add "scope" method
2012-07-14 07:06:51 -07:00
twinturbo
7936e3efba
Add "scope" method
2012-07-14 14:54:23 +02:00
José Valim
3e87c6414d
Merge pull request #92 from twinturbo/query-attributes
...
Close #86
2012-07-14 04:16:07 -07:00
twinturbo
2b9cd97436
Close #86
2012-07-14 13:12:26 +02:00
José Valim
d6a68ed14f
Merge pull request #85 from pushcx/master
...
Allow setting :each_serializer in 'render :json' calls
2012-07-14 04:05:40 -07:00
José Valim
b91e63c4ec
Merge pull request #88 from bradleypriest/ar-relation
...
Automatically include ArraySerializer in ActiveRecord::Relation
2012-07-11 04:04:38 -07:00
Bradley Priest
f41978b8de
move array_serializer logic to active_model_serializer.rb
2012-07-10 10:23:45 +08:00
Bradley Priest
7eb2b90b7c
Automatically include ArraySerializer in ActiveRecord::Relation
...
fixes #81
2012-07-10 10:17:54 +08:00
Peter Harkins
1c820a9ba7
Allow setting the serializer for ArraySerializer.
2012-06-21 11:12:13 -05:00
Yehuda Katz
1e777ced0e
Merge branch 'master' of github.com:josevalim/active_model_serializers
2012-06-20 00:56:31 -04:00
José Valim
09fac61b0a
Merge pull request #79 from teeparham/remove-hash-check
...
remove unncessary is_a?(Hash) check
2012-06-12 10:42:30 -07:00
Tee Parham
c898e3daf9
remove unncessary is_a?(Hash) check
2012-06-12 10:38:32 -07:00
José Valim
d956507482
Merge pull request #77 from alindeman/disable_serialization_scope
...
Allows serialization_scope to be disabled with serialization_scope nil
2012-06-11 23:50:18 -07:00
Yehuda Katz
615afd125c
Allow other resource overrides
2012-06-05 23:08:01 +02:00
Andy Lindeman
47850677e9
Allows serialization_scope to be disabled with serialization_scope nil
2012-06-05 12:37:09 -04:00
Yehuda Katz
00194ec0e4
Bump version
2012-06-05 10:18:59 +02:00
Yehuda Katz
7afac9cd5c
Fix the tests
2012-06-05 10:18:05 +02:00
Yehuda Katz
681bcf5ad7
Always add :id to attributes
2012-06-05 10:05:06 +02:00
twinturbo
2139a6d07a
Add AS::Notifications (thx @twinturbo)
2012-06-05 10:01:53 +02:00
Yehuda Katz
6e2554d741
Merge pull request #62 from highgroove/cleanup_scope_instance_variables
...
Remove left over references to scope instance variable
2012-06-05 00:32:23 -07:00
Yehuda Katz
3cb74887df
Merge pull request #65 from teeparham/array-root
...
use :root option in render :json
2012-06-05 00:31:13 -07:00
Yehuda Katz
64cb68107a
Merge pull request #67 from te-chris/patch-1
...
@scope seems to be deprecated - updated the readme to reflect options[:s...
2012-06-05 00:23:50 -07:00
Yehuda Katz
8376a4dcd1
Merge pull request #69 from teeparham/array-serializer
...
Array serializer should support Hash, AMS, and PORO
2012-06-05 00:23:17 -07:00
Yehuda Katz
dc942f47c1
Merge pull request #68 from teeparham/unique-test-methods
...
rename test methods so the tests run
2012-06-05 00:22:14 -07:00
Yehuda Katz
9919f28f4d
Merge pull request #75 from mauriciopasquier/master
...
fixing docs
2012-06-05 00:18:31 -07:00
Mauricio Pasquier Juan
7e80bce835
missing and duplicated id
2012-06-04 12:18:42 -03:00
José Valim
84aa3bc148
Merge pull request #73 from alindeman/rails-3-0-x
...
`rails generate` runs correctly under Rails 3.0.x
2012-06-01 07:10:59 -07:00
Andy Lindeman
9a3bd4770a
rails generate runs correctly under Rails 3.0.x
...
* Rails 3.0.x does not yield `app` to `generator` blocks in railties.
Picks a hopefully reasonable default `Rails.application` in that case.
* Fixes #71
2012-06-01 10:08:58 -04:00
Tee Parham
f35a2261d2
support different serializations in ArraySerializer
...
ArraySerializer can serialize arrays of Hash, ActiveModel::Serializer,
or any PORO that responds to :as_json
Each item in the array should not include its type as a root element,
since normal arrays do not do this. If you want "typed" collections,
don't use an Array.
2012-05-30 14:52:52 -06:00
Tee Parham
00db4dd6db
rename test methods so tests run
...
incidentally test_array_serializer_with_root fails
2012-05-30 11:14:49 -06:00
Tee Parham
9962069ae9
delete identical test
2012-05-30 10:55:35 -06:00