Sha256: f40d81550f9c6b741da343d68c71a61c1e5a58dc4a78f7b600ebed79b2e380f9

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

module Answers
  module <%= namespacing %>
    class <%= class_name %> < Answers::Core::BaseModel
<% if table_name == namespacing.underscore.pluralize -%>
      self.table_name = 'answers_<%= plural_name %>'
<% end %>
<% if localized? -%>

      translates <%= localized_attributes.map { |a| ":#{a.name}" }.join(', ') %>
<% end -%>
<% if string_attributes.any? -%>

      validates <%= string_attributes.first.name.to_sym.inspect %>, :presence => true, :uniqueness => true
<% else -%>

      # def title was created automatically because you didn't specify a string field
      # when you ran the answers:engine generator. <3 <3 Answers.
      def title
        "Override def title in vendor/extensions/<%= namespacing.underscore %>/app/models/answers/<%= namespacing.underscore %>/<%= singular_name %>.rb"
      end
<% end -%>
<% image_attributes.each do |a| -%>

      belongs_to :<%= a.name -%>, :class_name => '::Answers::Image'
<% end -%>
<% resource_attributes.each do |a| -%>

      belongs_to :<%= a.name %>, :class_name => '::Answers::Resource'
<% end -%>

      # To enable admin searching, add acts_as_indexed on searchable fields, for example:
      #
      #   acts_as_indexed :fields => [:title]

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
answers-core-0.0.0.2 lib/generators/answers/engine/templates/app/models/answers/namespace/singular_name.rb.erb
answers-core-0.0.0 lib/generators/answers/engine/templates/app/models/answers/namespace/singular_name.rb.erb