【问题标题】:Rails active admin undefined methodsRails 活动管理未定义方法
【发布时间】:2016-10-06 12:28:29
【问题描述】:

我正在使用此代码:

ActiveAdmin.register_page "Dashboard" do

    section "Recent Posts" do 
        table_for Post.order("id desc").limit(15) do
            column :id
            column "Post title", :title do |post|   
                link_to post.title,[:admin,post]
            end
            column :category,sortable: :category
            column :created_at
        end
        strong (link_to "Show all posts")
    end
end

我得到这个错误:

undefined method `section'

如果我删除 'section' do-end 部分,则会收到以下错误:

undefined method `table_for'

等等……

似乎我不能使用任何主动管理员给定的方法,也许我错过了什么?有什么宝石什么的?我使用此设置安装了活动管理 gem:

gem 'inherited_resources', github: 'activeadmin/inherited_resources'
gem 'activeadmin', github: 'activeadmin'
gem 'devise', github: 'plataformatec/devise'

我正在使用 Rails 5

【问题讨论】:

    标签: ruby-on-rails rubygems activeadmin


    【解决方案1】:

    我设法转换了我的代码,现在它编译没有任何错误。

    ActiveAdmin.register_page "Dashboard" do
      content :title => proc{ I18n.t("active_admin.dashboard") } do
        columns do
          column do
            panel "Recent Posts" do
              table_for Post.order("id desc").limit(5) do
                column :name do |post|
                  link_to post.title, [:admin, post]
                end
                column :created_at
              end
              strong (link_to "Show All Posts" , :posts )
            end
          end
        end
      end
    end
    

    我想我以前使用的语法很旧,不再受支持。

    【讨论】:

    猜你喜欢
    • 2011-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-16
    相关资源
    最近更新 更多