Reputation: 41
I realize that this issue is likely in my app code, but I'm stumped as to where to look at this point.
I've successfully installed ActiveAdmin 1.0.0.pre4 on rails 4.2.1 (following instructions these instructions. I turned off authentication, since we already have devise set up with a custom admin system and I will configure ActiveAdmin to use it once we know it's working for us. I also configured the default_namespace to be activeadmin (not admin) since we already have custom administration tools under /admin.
/activeadmin successfully shows the Dashboard. So I added two models (Contact and Flag). Flags (/activeadmin/flags) works as expected - it shows all the records and Id, View, and Edit all link to the appropriate details view.
For Contacts, the list view works as expected (/activeadmin/contacts). It shows the records and the filters seem to work.
The problem is if I click on the Id, View or Edit links for any Contact they all show the same content: the details view of one of my Page records (which I had not yet even configured for ActiveAdmin). They show the SAME Page details - it has the title "Contact Us" (and the slug "contact-us"). Everything in the ActiveAdmin UI looks as it should: the URL is /activeadmin/contacts/39, the breadcrumb is right, even the panel title says "Contact Details". But regardless of which contact I choose, it always shows the Contact Us page.
I can short-circuit it by editing the contact.rb file for ActiveAdmin. However, I can only get it to show the "title" (from the Page Contact Us), not any other field. Everything else (whether it's from the Page model or the Contact model) throws an exception: undefined local variable or method `body' for #<ActiveAdmin::Views::Pages::Show:0x007fdfff3e7c40>
Note that it's clearly looking for Pages, not Contacts. The request parameter is: {"controller"=>"activeadmin/contacts", "action"=>"show", "id"=>"39"}
Previously I had thought it had to do with the slug, although I have removed the friendly_id gem and commented out the code that references it (and errors imply it's no longer working). It made no difference.
Also:
- /activeadmin/contacts/ all show the Contact Us page details
- /activeadmin/contact-us or contact (with or without a /) gives a routing error (No route matches [GET] "/activeadmin/..."
)
I tried adding my Page model and then customizing page.rb with
ActiveAdmin.register Page, :as => "fancy_page"
(as I'd read in issue 959). But this did not change the behavior. Fancy Pages does indeed list all my pages, and Id, View, and Edit all link to the correct details page.
Rewriting my entire application to rename the Page model would be extremely difficult (the front-end website and associated custom CMS is the one part of our app that is fully working and live). I'm hoping there is a simpler fix, but I'm not really sure where to look.
Any suggestions?
Thanks!
julie
Upvotes: 2
Views: 262
Reputation: 1713
You need to customize the 'Form' configuration of contact's activeadmin resource by such configuration:
form do |f|
f.inputs 'Details' do
f.translated_inputs 'ignored title', switch_locale: false do |t|
t.input :name, :hint => 'Contact name'
t.input :email, :hint => 'Contact email'
end
end
actions
end
Note that you have to change name & email based on your model fields.
And to do more customization on the view (show
action), you can do it by:
show do |contact|
attributes_table do
row :id
row :name
row :email
end
end
Upvotes: 0