Always add :id to attributes

This commit is contained in:
Yehuda Katz 2012-06-05 10:05:06 +02:00
parent 2139a6d07a
commit 681bcf5ad7
2 changed files with 3 additions and 4 deletions

View File

@ -17,7 +17,7 @@ module Rails
private
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
def association_names

View File

@ -1,9 +1,8 @@
<% module_namespacing do -%>
class <%= class_name %>Serializer < <%= parent_class_name %>
<% if attributes.any? -%> attributes <%= attributes_names.map(&:inspect).join(", ") %>
<% end -%>
attributes <%= attributes_names.map(&:inspect).join(", ") %>
<% association_names.each do |attribute| -%>
has_one :<%= attribute %>
<% end -%>
end
<% end -%>
<% end -%>