1

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
6
  • Active admin won't create tables, I will create model objects, not tables. You can register any existing models and use form_for to create a form for creating rows and updating it. Commented Dec 29, 2018 at 23:52
  • Sorry, my question wasn't clear- I'm trying to create a table in the admin dashboard of recent object additions to the model. Just trying to view recent additions to a model. I will edit my question. Thanks for helping me rethink my question. Commented Dec 30, 2018 at 0:57
  • Post the error you are receiving. Commented Dec 30, 2018 at 12:03
  • I have had several different errors but the one I added to my post is the most common. Thanks! Commented Dec 30, 2018 at 18:29
  • paste the schema.rb file content for the Volunteer model. Commented Dec 30, 2018 at 18:30

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.