I have a file called messages_datatables.rb inside /app/datatables/admin/
class Admin::MessagesDatatable
delegate :params, :h, :link_to, :number_to_currency, to: :@view
.
.
.
private
def data
messages.map do |message|
[
"",
link_to(message.subject, admin_message_path(message))
]
end
end
.
.
.
.
end
I need use link_to
helper inside this file but I get:
NoMethodError (undefined method `admin_message_path' for #<Admin::MessagesDatatable:0xbe07170>):
The path is working fine in views. I have the path in my routes.
Where have I the error?
Add:
delegate :url_helpers, to: 'Rails.application.routes'
And instead of admin_message_path
, use url_helpers.admin_message_path