NoMethodError undefined method `link_to_function'

流过昼夜 提交于 2019-12-22 08:15:55

问题


I added ActiveAdmin to my app, updated some gems and now I get a undefined method `link_to_function' when viewing users show page. I have the will_paginate gem and I added a initializer so there's no conflict.

kaminari.rb:

Kaminari.configure do |config|
  config.page_method_name = :per_page_kaminari
end

The error points to the line on from /app/helpers/will_paginate_helper.rb:

  @template.link_to_function(text.to_s.html_safe, ajax_call, attributes)

回答1:


Add a helper method and it will fix your problem.

link_to_function_helper.rb:

module LinkToFunctionHelper
  def link_to_function(name, *args, &block)
     html_options = args.extract_options!.symbolize_keys

     function = block_given? ? update_page(&block) : args[0] || ''
     onclick = "#{"#{html_options[:onclick]}; " if html_options[:onclick]}#{function}; return false;"
     href = html_options[:href] || '#'

     content_tag(:a, name, html_options.merge(:href => href, :onclick => onclick))
  end
end


来源:https://stackoverflow.com/questions/26237059/nomethoderror-undefined-method-link-to-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!