Sha256: dd56e19fa933ef60ad1c4f658745750e19525961ce6e63f4f67d20811d57a1cf

Contents?: true

Size: 753 Bytes

Versions: 2

Compression:

Stored size: 753 Bytes

Contents

class <%= class_name %> < ActiveRecord::Base
<% attributes.select(&:reference?).each do |attribute| -%>
  belongs_to :<%= attribute.name %>
<% end -%>
<% for parent_model in parent_models -%>
  belongs_to :<%= parent_model.name.underscore %>
<% end -%>
<% for parent_model in parent_models -%>
  def <%= parent_model.name.underscore %>_<%= field_for(parent_model) %>
    <%= parent_model.name.underscore %>.<%= field_for(parent_model) %> if <%= parent_model.name.underscore %>
  end
  def <%= parent_model.name.underscore %>_<%= field_for(parent_model) %>=(<%= field_for(parent_model) %>)
    self.<%= parent_model.name.underscore %> = <%= parent_model.name %>.find_by_<%= field_for(parent_model) %>(<%= field_for(parent_model) %>)
  end
<% end -%>
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
view_mapper-0.3.4 lib/view_mapper/views/belongs_to_auto_complete/templates/model.erb
view_mapper-0.3.3 lib/view_mapper/views/belongs_to_auto_complete/templates/model.erb