trestle icon indicating copy to clipboard operation
trestle copied to clipboard

"Show" view; streamlined DSL for defining controllers/routes

Open Partytray opened this issue 2 years ago • 0 comments

Hi Sam, thanks for the great framework; it's been fairly smooth-sailing after using ActiveAdmin for so long.

Would you be open to PR introducing a "show" view? Right now I have it working with the default attributes, in addition to being able to extend the view without having to rewrite all the methods:

show do 
  default_attributes_table do 
    static_field :some_built_field do 
      "something"
    end
  end
  tab :payments do 
    # ... 
  end
end

which produces two tabs: one with a title of admin.model.model_name and another with "payments".

It mostly inherits from Form which is whatever, but it worked for my needs.

I also have a DSL for controller methods and routing; I found that having to redefine controller/routes every time was too time-consuming 🤣

controller_action :search, via: :get do 
  # ... 
end 

member_action :open, via: :post do 
  load_instance 

  # ... 
end 

which just does a define_method in the controller context and sets up routes. Let me know if you'd be open to that, too.

Partytray avatar Apr 04 '22 16:04 Partytray