ActiveAdmin.register_page Post do
controller do
def get_last_post
end
end
collection_action :get_details, method: :get do
data = get_last_post
end
end
data = get_last_post引发错误。
PS:职位不是模特。只是一页。
答案 0 :(得分:1)
在助手中添加方法。您可以从控制器和所有收集操作中访问该方法。
在帮助程序文件中添加方法,然后尝试从collection_action调用它
module PostHelper
def get_last_post
end
end
ActiveAdmin.register_page Post do
collection_action :get_details, method: :get do
data = get_last_post
end
end