本文介绍了NoMethodError未定义方法`link_to_function'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用程序中添加了ActiveAdmin,更新了一些gem,现在在查看用户显示页面时,得到了未定义的方法 link_to_function 。我有 will_paginate 宝石,并添加了一个初始化程序,所以没有冲突。

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.rb:

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

错误指向该行从/app/helpers/will_paginate_helper.rb开始:

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)


推荐答案

添加一个辅助方法,它将解决您的问题。

Add a helper method and it will fix your problem.

link_to_function_helper.rb:

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

这篇关于NoMethodError未定义方法`link_to_function'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 02:57
查看更多