2014-10-07 80 views
3

我在應用中添加了ActiveAdmin,更新了一些寶石,現在我在查看用戶顯示頁面時得到了一個undefined method `link_to_function'。我有will_paginate寶石,我添加了一個初始化程序,所以沒有衝突。NoMethodError undefined method`link_to_function'

kaminari.rb:

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

的錯誤點從/app/helpers/will_paginate_helper.rb就行了:

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

兩個分頁寶石一起?? – Nithin 2014-10-07 13:30:42

+4

在Rails 4.1.x中不推薦使用'link_to_function'方法。 – 2014-10-07 13:30:59

回答

14

添加一個輔助方法,它會解決您的問題。

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 
相關問題