DESIGN.textile in active_model_serializers-0.8.4 vs DESIGN.textile in active_model_serializers-0.9.0.alpha1
- old
+ new
@@ -356,23 +356,23 @@
You can use the <code:key</code> option to specify a different name for an association.
Here is an example:
<pre lang="ruby">
class UserSerializer < ActiveModel::Serializer
- has_many :followed_posts, :key => :posts
- has_one :owned_account, :key => :account
+ has_many :followed_posts, key: :posts
+ has_one :owned_account, key: :account
end
</pre>
Using the <code>:key</code> without a <code>:serializer</code> option will use implicit detection
to determine a serializer. In this example, you'd have to define two classes: <code>PostSerializer</code>
and <code>AccountSerializer</code>. You can also add the <code>:serializer</code> option
to set it explicitly:
<pre lang="ruby">
class UserSerializer < ActiveModel::Serializer
- has_many :followed_posts, :key => :posts, :serializer => CustomPostSerializer
- has_one :owne_account, :key => :account, :serializer => PrivateAccountSerializer
+ has_many :followed_posts, key: :posts, serializer: CustomPostSerializer
+ has_one :owne_account, key: :account, serializer: PrivateAccountSerializer
end
</pre>
h3. Customizing Associations