Closed Uysim closed 7 years ago
Can you show more full version of code you work with?
class UsersGrid
include Datagrid
scope do
User
end
decorate { |user| UserDecorator.new(user) }
filter(:name, header: -> { I18n.t('users.index.name') }) do |value, scope|
scope.where('name iLIKE ?', "%#{value.downcase}%")
end
filter(:email, header: -> { I18n.t('users.index.email') })
filter(:role, :enum, select: User::ROLES.map {|r| [r.humanize, r]}, header: -> { I18n.t('users.index.role') }, class: 'select-material')
column(:avatar, header: -> { I18n.t('users.avatar') }, order: false, html: true) do |object|
link_to image_tag(object.avatar.thumb, class: 'circle', alt: object.name), user_path(object)
end
column(:name, header: -> { I18n.t('users.index.name') }, html: true ) do |object|
link_to object.name, user_path(object)
end
column(:email, header: -> { I18n.t('users.index.email') })
column(:role, header: -> { I18n.t('users.index.role') }) do |object|
object.role.humanize.titleize
end
column(:status, header: -> { I18n.t('users.index.status') }, html: true, order: 'approved, role' ) do |object|
object.approval_status
end
column(:action, header: -> { I18n.t('users.index.action') }, html: true ) do |object|
render 'users/actions', object: object
end
end
I have no problem making it work. Can you show your controller and the view too?
Closing for inactivity
I use gem draper
decorate { UserDecorator }
But datagrid did not decorate at all I use datagrid version 1.5.1