Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails active admin undefined methods

I'm using this code:

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

and I get this error:

undefined method `section'

if I delete 'section' do-end part, then I get error for:

undefined method `table_for'

and so on...

Seems like I cant use any of active admin given methods, maybe I'm mising something? Any gems or something? I installed active admin gem using this setup:

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

I'm using rails 5

like image 778
Justas Avatar asked Oct 06 '16 12:10

Justas


1 Answers

I managed to transform my code and now it compiles without any errors.

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

I suppose my previously used syntax is old and not supported any more.

like image 128
Justas Avatar answered Oct 18 '22 08:10

Justas