Sha256: 6026cd661f9cc6c0c28647b05e8351c670b50a985a02dbe46a58e0ad943cd3e4

Contents?: true

Size: 968 Bytes

Versions: 2

Compression:

Stored size: 968 Bytes

Contents

class MessageDatatable < AjaxDatatablesRails::Base
  def_delegators :@view, :link_to, :manage_message_path, :display_datetime

  def view_columns
    @view_columns ||= {
      id: { source: "Message.id" },
      name: { source: "Message.name" },
      subject: { source: "Message.subject" },
      trigger: { source: "Message.trigger" },
      delivered_at: { source: "Message.delivered_at", searchable: false }
    }
  end

  private

  def data
    records.map do |record|
      {
        id: record.id,
        name: link_to(record.name, manage_message_path(record)),
        subject: record.subject,
        trigger: Message::POSSIBLE_TRIGGERS[record.trigger],
        status: record.status.titleize,
        delivered_at: record.delivered_at.present? ? display_datetime(record.delivered_at) : ''
      }
    end
  end

  # rubocop:disable Naming/AccessorMethodName
  def get_raw_records
    Message.unscoped
  end
  # rubocop:enable Naming/AccessorMethodName
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hackathon_manager-0.7.1 app/datatables/message_datatable.rb
hackathon_manager-0.7.0 app/datatables/message_datatable.rb