Commit 83e721bc by liyijie

feat: add extract_view_attributes to view templates

parent 36b33f87
json.partial! '<%= view_path %>/simple', <%= resource_singular %>: <%= resource_singular %>
json.extract!(
<%= resource_singular %>,
*<%= resource_singular %>.class.try(:extra_view_attributes, 'detail'),
)
<%- if detail_attribute_names.present? -%>
json.extract!(
......
json.partial! '<%= view_path %>/single', <%= resource_singular %>: <%= resource_singular %>
json.extract!(
<%= resource_singular %>,
*<%= resource_singular %>.class.try(:extra_view_attributes, 'simple'),
)
<%- belongs_to_refs.each do |ref| -%>
json.<%= ref.name.to_s %> <%= resource_singular %>.<%= ref.name.to_s %>, partial: '<%= File.join(ref.klass.name.underscore.pluralize, 'single') %>', as: :<%= ref.name %>
......
<%- if active_record? -%>
json.extract!(
<%= resource_singular %>,
*<%= resource_singular %>.class.try(:extra_permitted_attributes),
*<%= resource_singular %>.class.try(:extra_view_attributes, 'single'),
:id,
:created_at,
:updated_at,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment