mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 14:56:50 +00:00
Always add :id to attributes
This commit is contained in:
parent
2139a6d07a
commit
681bcf5ad7
@ -17,7 +17,7 @@ module Rails
|
|||||||
private
|
private
|
||||||
|
|
||||||
def attributes_names
|
def attributes_names
|
||||||
attributes.select { |attr| !attr.reference? }.map { |a| a.name.to_sym }
|
[:id] + attributes.select { |attr| !attr.reference? }.map { |a| a.name.to_sym }
|
||||||
end
|
end
|
||||||
|
|
||||||
def association_names
|
def association_names
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
<% module_namespacing do -%>
|
<% module_namespacing do -%>
|
||||||
class <%= class_name %>Serializer < <%= parent_class_name %>
|
class <%= class_name %>Serializer < <%= parent_class_name %>
|
||||||
<% if attributes.any? -%> attributes <%= attributes_names.map(&:inspect).join(", ") %>
|
attributes <%= attributes_names.map(&:inspect).join(", ") %>
|
||||||
<% end -%>
|
|
||||||
<% association_names.each do |attribute| -%>
|
<% association_names.each do |attribute| -%>
|
||||||
has_one :<%= attribute %>
|
has_one :<%= attribute %>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user