dbate
dbate

Reputation: 127

Active Admin Errors

I am using active admin for the first time, and I don't know much about it. I'm trying to create a table (in admin dashboard view) that shows certain details of the model object (which are created via form submission.)

I simply want to be able to view recent additions to the model object from the admin dashboard.

I've read the documentation on Active Admin, but it seems like most of it is using examples that don't entirely meet what I'm trying to do. (Or it could just be that I am a newbie at this)

I've looked at a few forums and found some examples, but even they use multiple variations on the table_for method.

I am getting this error:

NoMethodError in Admin::Dashboard#index Showing C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activeadmin-1.4.3/app/views/active_admin/page/index.html.arb where line #2 raised:

undefined method `first_name' for # Did you mean? sti_name

Any insight or advice would be appreciated. I've posted my code from dashboard.rb below:

ActiveAdmin.register_page "Dashboard" do   content :title => proc{ I18n.t("active_admin.dashboard") } do columns do    column do
    panel "New Teacher Applicants" do
      table_for Volunteer do |t|
        t.column("Name") { |volunteer| volunteer.first_name }
        t.column("Surname") { |volunteer| volunteer.last_name }
        t.column("Email") { |volunteer| volunteer.email }
        t.column("Gender") { |volunteer| volunteer.gender }

      end

    end   end end

 end end

Upvotes: 1

Views: 721

Answers (1)

Sjors Branderhorst
Sjors Branderhorst

Reputation: 2182

I think this is what you are looking for:

panel 'New Teacher Applicants' do
  table_for Volunteer.order("created_at desc").take(5) do
    column "Name", :first_name
    column "Surname", :last_name
    column "Email", :email
    column "Gender", :gender
  end
end

The argument to table_for should be a collection. Maybe take a closer look: https://activeadmin.info/12-arbre-components.html#table-for

Upvotes: 1

Related Questions