i'd like to create settings page via activeadmin (edit/update). https://github.com/huacnlee/rails-settings-cached.
But i faced that there is no way to register resource (not resources) in routes for particular page, eg have routes like /admin/settings, but not admin/settings/:id
inherit_resource has
defaults singleton: true
for this case, but this doesnt work for activeadmin.
Please help.
Otherwise, i can go with register_pagse way and create form myself and update action,but another problem appeared: how can i render errors messages on form from that update action.
The singleton way is way preferred.
You can always force the index action to redirect to the singleton resource that you want. While this is not a perfect solution, I have used it in the past. Something like this:
ActiveAdmin.register Setting, as: 'Setting' do
  actions :all, only: [:show, :edit, :update, :index]
  controller do
    def index
      redirect_to resource_path(Setting.first)
    end
  end
end
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With