Sha256: 8a5469077ed8d42ef35c39b1fbc73711fe11e733eafefa0606b3085adbd4d980

Contents?: true

Size: 954 Bytes

Versions: 7

Compression:

Stored size: 954 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? %><%= ', required: true' if attribute.required? %>
<% end -%>
<% attributes.select(&:token?).each do |attribute| -%>
  has_secure_token<% if attribute.name != "token" %> :<%= attribute.name %><% end %>
<% end -%>
<% if attributes.any?(&:password_digest?) -%>
  has_secure_password
<% end -%>
  
  include LiveRecord::Model::Callbacks
  has_many :live_record_updates, as: :recordable, dependent: :destroy

  def self.live_record_whitelisted_attributes(<%= class_name.underscore %>, current_user)
    # Add attributes to this array that you would like current_user to have access to.
    # Defaults to empty array, thereby blocking everything by default, only unless explicitly stated here so.
    []
  end
end
<% end -%>

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
live_record-0.2.6 lib/live_record/generators/templates/model.rb.rb
live_record-0.2.5 lib/live_record/generators/templates/model.rb.rb
live_record-0.2.4 lib/live_record/generators/templates/model.rb.rb
live_record-0.2.3 lib/live_record/generators/templates/model.rb.rb
live_record-0.2.2 lib/live_record/generators/templates/model.rb.rb
live_record-0.2.1 lib/live_record/generators/templates/model.rb.rb
live_record-0.2.0 lib/live_record/generators/templates/model.rb.rb