Files
nairobi/app/components/admin/roles/table_actions_component.rb
Javi Martín ccb7695056 Use a custom link_to method for table actions
This way we'll be able to change the behavior of these links without
changing the view nor affecting the rest of the application.
2020-11-03 14:58:02 +01:00

32 lines
567 B
Ruby

class Admin::Roles::TableActionsComponent < ApplicationComponent
include TableActionLink
attr_reader :record, :actions
def initialize(record, actions: [:destroy])
@record = record
@actions = actions
end
private
def role
record.class.name.tableize
end
def already_has_role?
record.persisted?
end
def add_user_text
t("admin.#{role}.#{role.singularize}.add")
end
def add_user_path
{
controller: "admin/#{role}",
action: :create,
user_id: record.user
}
end
end