|
81 | 81 | ```ruby |
82 | 82 | has_one :bio |
83 | 83 | has_one :blog, key: :site |
| 84 | +has_one :blog, class_name: "Blog" |
84 | 85 | has_one :maker, virtual_value: { id: 1 } |
85 | 86 |
|
86 | 87 | has_one :blog do |serializer| |
|
114 | 115 | has_many :comments |
115 | 116 | has_many :comments, key: :reviews |
116 | 117 | has_many :comments, serializer: CommentPreviewSerializer |
| 118 | +has_many :comments, class_name: "Comment" |
117 | 119 | has_many :reviews, virtual_value: [{ id: 1 }, { id: 2 }] |
118 | 120 | has_many :comments, key: :last_comments do |
119 | 121 | last(1) |
|
127 | 129 | ```ruby |
128 | 130 | belongs_to :author, serializer: AuthorPreviewSerializer |
129 | 131 | belongs_to :author, key: :writer |
| 132 | +belongs_to :author, class_name: "Author" |
130 | 133 | belongs_to :post |
131 | 134 | belongs_to :blog |
132 | 135 | def blog |
|
294 | 297 | Whether you write the method as above or as `object.comments.where(created_by: scope)` |
295 | 298 | is a matter of preference (assuming `scope_name` has been set). |
296 | 299 |
|
297 | | -Keep in mind that the scope can be set to any available controller reference. This can be utilized to provide access to any other data scopes or presentation helpers. |
| 300 | +Keep in mind that the scope can be set to any available controller reference. This can be utilized to provide access to any other data scopes or presentation helpers. |
298 | 301 |
|
299 | 302 | ##### Controller Authorization Context |
300 | 303 |
|
@@ -381,7 +384,7 @@ class PostsController < ActionController::Base |
381 | 384 | end |
382 | 385 | end |
383 | 386 | ``` |
384 | | -Note that any controller reference which provides the desired scope is acceptable, such as another controller method for loading a different resource or reference to helpers. For example, `ActionController::API` does not include `ActionView::ViewContext`, and would need a different reference for passing any helpers into a serializer via `serialization_scope`. |
| 387 | +Note that any controller reference which provides the desired scope is acceptable, such as another controller method for loading a different resource or reference to helpers. For example, `ActionController::API` does not include `ActionView::ViewContext`, and would need a different reference for passing any helpers into a serializer via `serialization_scope`. |
385 | 388 |
|
386 | 389 | #### #read_attribute_for_serialization(key) |
387 | 390 |
|
|
0 commit comments