Sha256: 494461c732668c9db82c28b21148f492dd5a53cd2eff01a65b04f7700419dd36

Contents?: true

Size: 871 Bytes

Versions: 1

Compression:

Stored size: 871 Bytes

Contents

<% module_namespacing do -%>
class <%= class_name %> < <%= parent_class_name.classify %>
  unloadable

<% attributes.select {|attr| attr.reference? }.each do |attribute| -%>
  belongs_to :<%= attribute.name %>
<% end -%>
<% if parent_options[:author] -%>
  belongs_to :author, <%= key_value :class_name, '"User"' %>, <%= key_value :foreign_key, '"author_id"' %>
<% end -%>
<% if parent_options[:project] -%>
  belongs_to :project
<% end -%>
<% if !accessible_attributes.empty? -%>
  attr_accessible <%= accessible_attributes.map {|a| ":#{a.name}" }.sort.join(', ') %>
<% else -%>
  # attr_accessible :title, :body
<% end -%>
<% if parent_options[:project] || parent_options[:author] -%>

  validates <%= [(":project" if parent_options[:project]), (":author" if parent_options[:author])].compact.join ", " %>, <%= key_value :presence, "true" %>

<% end -%>
end
<% end -%>

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
redmine-generators-0.0.1 lib/redmine/generators/templates/active_record/model/model.rb