Sha256: 6d2299ff3540168738d57cf7222fba838cf904ad03f12ae4ce272e4077016ea2

Contents?: true

Size: 1.73 KB

Versions: 2

Compression:

Stored size: 1.73 KB

Contents

<% module_namespacing do -%>
class <%= class_name %> < <%= parent_class_name.classify %>
  # Enable if you need to generate attachment URLs
  # include Rails.application.routes.url_helpers
  
<% attributes.select(&:reference?).each do |attribute| -%>
  belongs_to :<%= attribute.name %><%= ', polymorphic: true' if attribute.polymorphic? %>
<% end -%>
<% attributes.select(&:attachment?).each do |attribute| -%>
  has_one_attached :<%= attribute.name %>
<% end -%>
<% attributes.select(&:attachments?).each do |attribute| -%>
  has_many_attached :<%= attribute.name %>
<% end -%>

  def list_item_as_json
    {
      id: id,
      text: text,
      # detailText: nil,
      # sfSymbolName: nil,
      # imageURL: preview_url(image, height: 100, width: 100)
    }
  end
  
  def display_as_json
    [
      {label: "ID", text: text, mimeType: 'text/plain'},
      {label: "Text", text: text, mimeType: 'text/plain'}
    ]
  end
  
  # private
  # include Rails.application.routes.url_helpers # for attachment URLs
  # def preview_url(attachment, height:, width:, options: { resize_to_fill: [height, width]} )
  #   return nil unless attachment.attached?
  #
  #   if attachment.image?
  #     Rails.application.routes.url_helpers.rails_representation_url(attachment.variant(combine_options: options), host: attachment_host)
  #   elsif attachment.previewable?
  #     Rails.application.routes.url_helpers.rails_representation_url(attachment.preview(options), host: attachment_host)
  #   else
  #     return nil
  #   end
  # end
  #
  # def attachment_url(attachment)
  #   Rails.application.routes.url_helpers.rails_blob_url(attachment, host: attachment_host)
  # end
  #
  # def attachment_host
  #   "https://#{ENV['HEROKU_APP_NAME']}.herokuapp.com"
  # end

end
<% end -%>

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
mobile_workflow-0.1.0 lib/templates/active_record/model/model.rb.erb
mobile_workflow_cli-0.1.4 templates/model.rb