Sha256: 520a1897d62906d838874ff50a29bdcde80861f581fe928ee1dc5fbff41b1ff1

Contents?: true

Size: 600 Bytes

Versions: 4

Compression:

Stored size: 600 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? %>
<% end -%>
<% if attributes.any?(&:password_digest?) -%>
  has_secure_password
<% end -%>
<% attribute = attributes.detect{|a| a.name == 'position'} || attributes.detect{|a| a.name == 'name'} || attributes.detect{|a| a.name == 'title'} || attributes.first -%>
<% if attribute -%>
  scope :ordered, -> { order(:<%=attribute.name %>) }
<% end -%>

end
<% end -%>

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
active_record_model_and_rspec_enhanced_templates-1.0.3 lib/templates/active_record/model/model.rb
active_record_model_and_rspec_enhanced_templates-1.0.2 lib/templates/active_record/model/model.rb
active_record_model_and_rspec_enhanced_templates-1.0.1 lib/templates/active_record/model/model.rb
active_record_model_and_rspec_enhanced_templates-1.0.0 lib/templates/active_record/model/model.rb