Sha256: fe9007f389f8bb07e3de94e039660a94c42c3c57b4f04e9d0542b1d0558ee116
Contents?: true
Size: 1.4 KB
Versions: 3
Compression:
Stored size: 1.4 KB
Contents
class ApplicationGrid < Datagrid::Base self.default_column_options = { # Uncomment to disable the default order # order: false, # Uncomment to make all columns HTML by default # html: true, } # Enable forbidden attributes protection # self.forbidden_attributes_protection = true # Makes a date column # @param name [Symbol] Column name # @param args [Array] Other column helper arguments # @example # date_column(:created_at) # date_column(:owner_registered_at) do |model| # model.owner.registered_at # end def self.date_column(name, *args, &block) column(name, *args) do |model| format(block ? block.call(model) : model.public_send(name)) do |date| date&.strftime("%m/%d/%Y") || "—".html_safe end end end # Makes a boolean YES/NO column # @param name [Symbol] Column name # @param args [Array] Other column helper arguments # @example # boolean_column(:approved) # boolean_column(:has_tasks, preload: :tasks) do |model| # model.tasks.unfinished.any? # end def self.boolean_column(name, *args, &block) column(name, *args) do |model| value = block ? block.call(model) : model.public_send(name) value ? "Yes" : "No" end end # Uncomment to shorten URL query string for all grids. # May cause collisions if multiple grids are used on the same page. # def param_name # 'grid' # end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
datagrid-2.0.1 | templates/base.rb.erb |
datagrid-2.0.0 | templates/base.rb.erb |
datagrid-2.0.0.pre.alpha | templates/base.rb.erb |