wice_grid gem によって作成された次のテーブルがあり、ユーザーが選択した状態に応じて「現在の状態」列の動的 css を作成する必要があります。状態モデルには既に色属性と背景属性があります。
<div class="tab-content">
<div class="tab-pane active" id="tab1">
<p><%= grid(@tickets_grid, show_filters: :when_filtered) do |g|
g.column name: 'Ticket title', attribute: 'title', :auto_reload => true
g.column name: 'Publish Date' do |ticket|
time_ago_in_words(ticket.created_at)
end
g.column name: 'Sender', attribute: 'user_name', model: 'User', auto_reload: true do |ticket|
ticket.user.user_name if ticket.user
end
g.column name: 'Sender role', attribute: 'type_of_user', model: 'UserType', auto_reload: true do |ticket|
ticket.user.user_type.type_of_user if ticket.user
end
g.column name: 'Assigned Department', attribute: 'name', model: 'EmployeeDepartment', auto_reload: true do |ticket|
ticket.employee_department.name if ticket.employee_department
end
g.column name: 'Current State', attribute: 'name', model: 'State', auto_reload: true do |ticket|
if ticket.state
ticket.state.name
else
Not defined yet
end
end
g.column do |ticket|
link_to('Read this thread', ticket_path(ticket))
end
end -%></p>
</div>