Я очень внимательно слежу за тем, чтобы настроить простую фильтрацию на модели игроков, используя в качестве примера http://filterrific.clearcove.ca/pages/action_view_api.html. Тем не менее, я продолжаю получать синтаксическую ошибку ниже, ясно, что я что-то здесь упускаю!
Ошибка
syntax error, unexpected '<', expecting ')'
</div>
^
/home/jack/Itorix/app/views/players/_list.html.erb:10: unknown regexp options - th
Контроллер игроков
def index
@filterrific = initialize_filterrific(
Player,
params[:filterrific]
) || return
@players = @filterrific.find.page(params[:page])
respond_to do |format|
format.html
format.js
end
end
Модель игроков
class Player < ApplicationRecord
filterrific(
default_filter_params: { sorted_by: 'tornid' },
available_filters: [
:sorted_by,
])
scope :sorted_by, ->(sort_option) {
# extract the sort direction from the param value.
direction = /desc$/.match?(sort_option) ? "desc" : "asc"
case sort_option.to_s
when /^tornid/
# Simple sort on the created_at column.
# Make sure to include the table name to avoid ambiguous column names.
# Joining on other tables is quite common in Filterrific, and almost
# every ActiveRecord table has a 'created_at' column.
order("players.tornid #{direction}")
else
raise(ArgumentError, "Invalid sort option: #{sort_option.inspect}")
end
}
end
Индекс. html .erb
<p id="notice"><%= notice %></p>
<h1>Players</h1>
<% js = escape_javascript(
render(partial: 'players/list', locals: { players: @players })
) %>
$("#filterrific_results").html("<%= js %>");
<%= form_for_filterrific @filterrific do |f| %>
<div>
Sorted by
<%= f.select(:sorted_by, @filterrific.select_options[:sorted_by]) %>
</div>
<div>
<%= link_to(
'Reset filters',
reset_filterrific_url,
) %>
</div>
<%# add an automated spinner to your form when the list is refreshed %>
<%= render_filterrific_spinner %>
<% end %>
<%= render(
partial: 'players/list',
locals: { players: @players }
) %>
<%= link_to "New Player", new_player_path %>
_list. html .erb
<%# app/views/players/_list.html.erb %>
<div id="filterrific_results">
<div>
<%= page_entries_info players # provided by will_paginate %>
</div>
<table>
<tr>
<th><%= filterrific_sorting_link(@filterrific, :tornid) %></th>
</tr>
<% players.each do |player| %>
<tr>
<td><%= player.tornid %></td>
</tr>
<% end %>
</table>
</div>
<%= will_paginate players # provided by will_paginate %>