Sha256: 33d986834ca2d6a9534571d6dc8e0b7c54cdd37cbe4cddbe748e87781d1253d0

Contents?: true

Size: 979 Bytes

Versions: 10

Compression:

Stored size: 979 Bytes

Contents

class SchoolDatatable < AjaxDatatablesRails::Base
  def_delegators :@view, :link_to, :manage_school_path, :manage_bus_list_path, :bold

  def view_columns
    @view_columns ||= {
      id: { source: 'School.id', cond: :eq },
      name: { source: 'School.name' },
      city: { source: 'School.city' },
      state: { source: 'School.state' },
      questionnaire_count: { source: 'School.questionnaire_count', searchable: false }
    }
  end

  private

  def data
    records.map do |record|
      {
        id: record.id,
        name: link_to(bold(record.name), manage_school_path(record)),
        city: record.city,
        state: record.state,
        questionnaire_count: record.questionnaire_count,
        bus_list: record.bus_list ? link_to(record.bus_list.name, manage_bus_list_path(record.bus_list)) : ''
      }
    end
  end

  # rubocop:disable Naming/AccessorMethodName
  def get_raw_records
    School.all
  end
  # rubocop:enable Naming/AccessorMethodName
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
hackathon_manager-0.11.2 app/datatables/school_datatable.rb
hackathon_manager-0.11.1 app/datatables/school_datatable.rb
hackathon_manager-0.11.0 app/datatables/school_datatable.rb
hackathon_manager-0.10.3 app/datatables/school_datatable.rb
hackathon_manager-0.10.2 app/datatables/school_datatable.rb
hackathon_manager-0.10.1 app/datatables/school_datatable.rb
hackathon_manager-0.10.0 app/datatables/school_datatable.rb
hackathon_manager-0.9.2 app/datatables/school_datatable.rb
hackathon_manager-0.9.1 app/datatables/school_datatable.rb
hackathon_manager-0.9.0 app/datatables/school_datatable.rb