我在/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
我需要在此文件中使用link_to
帮助器,但我得到:
NoMethodError (undefined method `admin_message_path' for #<Admin::MessagesDatatable:0xbe07170>):
路径在视图中正常工作。我的路线上有路径。
我的错误在哪里?
答案 0 :(得分:1)
添加:
delegate :url_helpers, to: 'Rails.application.routes'
而不是admin_message_path
,请使用url_helpers.admin_message_path