Sha256: 2492b930ee2c02120402ed58bdfb5c71f3973f840f3d4adecc20f37cf204220b

Contents?: true

Size: 1.21 KB

Versions: 3

Compression:

Stored size: 1.21 KB

Contents

class <%= class_name %>Decorator < Tramway::ApplicationDecorator
  # Associations you want to show in admin dashboard
  # decorate_associations :messages, :posts

  delegate_attributes(
<% attributes.each do |attr| -%>
        :<%= attr %>,
<% end -%>
  )

  class << self
    def collections
      # [ :all, :scope1, :scope2 ]
      [ :all ]
    end

    def list_attributes
      [
<% attributes.first(COLLECTION_ATTRIBUTE_LIMIT).each do |attr| -%>
        :<%= attr %>,
<% end -%>
      ]
    end

    def show_attributes
      [
<% attributes.each do |attr| -%>
        :<%= attr %>,
<% end -%>
      ]
    end

    def show_associations
      # Associations you want to show in admin dashboard
      # [ :messages ]
    end

    def list_filters
      # {
      #   filter_name: {
      #     type: :select,
      #     select_collection: filter_collection,
      #     query: lambda do |list, value|
      #       list.where some_attribute: value
      #     end
      #   },
      #   date_filter_name: {
      #     type: :dates,
      #     query: lambda do |list, begin_date, end_date|
      #       list.where 'created_at > ? AND created_at < ?', begin_date, end_date
      #     end
      #   }
      # }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tramway-0.1.2 lib/tramway/generators/templates/decorator.rb.erb
tramway-0.1.1.1 lib/tramway/generators/templates/decorator.rb.erb
tramway-0.1.1 lib/tramway/generators/templates/decorator.rb.erb