Commit bf571fef authored by Kaspar Vollenweider's avatar Kaspar Vollenweider 👻 Committed by Kaspar
Browse files

first ransack sorters

parent d68f2b3f
......@@ -4,8 +4,8 @@ class VolunteersController < ApplicationController
before_action :set_state, only: [:update]
def index
@volunteers = Volunteer.all
authorize Volunteer
@q = Volunteer.ransack(params[:q])
@volunteers = @q.result(distinct: true)
end
def show; end
......@@ -60,6 +60,10 @@ class VolunteersController < ApplicationController
authorize @volunteer
end
def filter_params
params.require(:volunteer).permit(:q)
end
def volunteer_params
params.require(:volunteer).permit(
volunteer_attributes,
......
......@@ -2,6 +2,7 @@ tr
td = volunteer.full_name
td = volunteer.date_of_birth
td = country(volunteer.nationality)
td = volunteer.created_at
td = t("gender.#{volunteer.gender}") unless volunteer.gender.blank?
td = t("simple_form.options.volunteer.state.#{volunteer.state}")
td = link_to t_action(:show), volunteer
......
......@@ -8,10 +8,11 @@
thead
tr
th= t_attr(:full_name)
th= t_attr(:date_of_birth)
th= sort_link @q, :date_of_birth
th= t_attr(:nationality)
th= t_attr(:gender)
th= t_attr(:state)
th= sort_link @q, :created_at
th= sort_link @q, :gender
th= sort_link @q, :state
th colspan='3'
tbody
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment