From d769cbac3760231c5efb2e01ad11cd7ec5f196e4 Mon Sep 17 00:00:00 2001 From: Kashif Tariq <47936915+kashiftariq1997@users.noreply.github.com> Date: Tue, 17 Aug 2021 01:44:59 +0500 Subject: [PATCH] Documentation (#90) * added docs for custom fields and resources * Added docs for routes and views --- docs/custom_fields.md | 14 ++++++++++++++ docs/resources.md | 7 +++++++ docs/routes.md | 7 +++++++ docs/views.md | 8 ++++++++ 4 files changed, 36 insertions(+) create mode 100644 docs/custom_fields.md create mode 100644 docs/resources.md create mode 100644 docs/routes.md create mode 100644 docs/views.md diff --git a/docs/custom_fields.md b/docs/custom_fields.md new file mode 100644 index 0000000..a82a2ee --- /dev/null +++ b/docs/custom_fields.md @@ -0,0 +1,14 @@ +## Custom Fields +You can generate a custom field with: + +rails g madmin:field Custom +This will create a CustomField class in app/madmin/fields/custom_field.rb And the related views: + +# -> app/views/madmin/fields/custom_field/_form.html.erb +# -> app/views/madmin/fields/custom_field/_index.html.erb +# -> app/views/madmin/fields/custom_field/_show.html.erb +You can then use this field on our resource: + +class PostResource < Madmin::Resource + attribute :title, field: CustomField +end \ No newline at end of file diff --git a/docs/resources.md b/docs/resources.md new file mode 100644 index 0000000..db88d94 --- /dev/null +++ b/docs/resources.md @@ -0,0 +1,7 @@ +# Resources +Madmin uses Resource classes to add models to the admin area. + +## Generate a Resource +To generate a resource for a model, you can run: + +rails g madmin:resource ActionText::RichText diff --git a/docs/routes.md b/docs/routes.md new file mode 100644 index 0000000..bde0c03 --- /dev/null +++ b/docs/routes.md @@ -0,0 +1,7 @@ +# Routes +Routes should be under the namespace of madmin module.Like +namespace :madmin do + namespace :user do + resources :connected_accounts + end + end \ No newline at end of file diff --git a/docs/views.md b/docs/views.md new file mode 100644 index 0000000..2aa371c --- /dev/null +++ b/docs/views.md @@ -0,0 +1,8 @@ +# Configuring Views +The views packaged within the gem are a great starting point, but inevitably people will need to be able to customize those views. + +You can use the included generator to create the appropriate view files, which can then be customized. + +For example, running the following will copy over all of the views into your application that will be used for every resource: + +rails generate madmin:views