Sha256: e8b6dc7c055ba9fcc68100bf7adb8273762b1d4af8b9380cb207dc935f0ec83d

Contents?: true

Size: 692 Bytes

Versions: 3

Compression:

Stored size: 692 Bytes

Contents

<% module_namespacing do -%>
class <%= class_name %> < <%= parent_class_name.classify %>
<% attributes.select(&:reference?).each do |attribute| -%>
  belongs_to :<%= attribute.name %><%= ', polymorphic: true' if attribute.polymorphic? %><%= ', optional: true' unless attribute.required? %>
<% end -%>
<% if attributes.any?(&:password_digest?) -%>
  has_secure_password
<% end -%>
<%
  attributes_to_show = attributes.reject(&:password_digest?)
  title_attribute = attributes_to_show.find do |attr|
    ["name", "title"].include? attr.name
  end || attributes_to_show.first
-%>
<% if title_attribute.present? -%>
  def to_title
    <%= title_attribute.name %>
  end
<% end -%>
end
<% end -%>

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
silmarails-0.3.4 lib/generators/silmarails/install/files/templates/active_record/model/model.rb
silmarails-0.3.2 lib/generators/silmarails/install/files/templates/active_record/model/model.rb
silmarails-0.3.1 lib/generators/silmarails/install/files/templates/active_record/model/model.rb