File: partial.json.jbuilder

package info (click to toggle)
ruby-jbuilder 2.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 304 kB
  • sloc: ruby: 2,112; makefile: 3
file content (16 lines) | stat: -rw-r--r-- 758 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
json.extract! <%= singular_table_name %>, <%= full_attributes_list %>
json.url <%= singular_table_name %>_url(<%= singular_table_name %>, format: :json)
<%- virtual_attributes.each do |attribute| -%>
<%- if attribute.type == :rich_text -%>
json.<%= attribute.name %> <%= singular_table_name %>.<%= attribute.name %>.to_s
<%- elsif attribute.type == :attachment -%>
json.<%= attribute.name %> url_for(<%= singular_table_name %>.<%= attribute.name %>)
<%- elsif attribute.type == :attachments -%>
json.<%= attribute.name %> do
  json.array!(<%= singular_table_name %>.<%= attribute.name %>) do |<%= attribute.singular_name %>|
    json.id <%= attribute.singular_name %>.id
    json.url url_for(<%= attribute.singular_name %>)
  end
end
<%- end -%>
<%- end -%>