README.md in activeadmin_dynamic_fields-0.2.6 vs README.md in activeadmin_dynamic_fields-0.2.8

- old
+ new

@@ -106,39 +106,39 @@ - Prepare a custom member action to save data, an *update* helper function is available (third parameter is optional, allow to filter using strong parameters): ```rb member_action :save, method: [:post] do - render ActiveAdmin::DynamicFields::update( resource, params ) - # render ActiveAdmin::DynamicFields::update( resource, params, [:published] ) - # render ActiveAdmin::DynamicFields::update( resource, params, Article::permit_params ) + render ActiveAdmin::DynamicFields.update(resource, params) + # render ActiveAdmin::DynamicFields.update(resource, params, [:published]) + # render ActiveAdmin::DynamicFields.update(resource, params, Article::permit_params) end ``` - In *index* config: ```rb # Edit a string: column :title do |row| - div row.title, ActiveAdmin::DynamicFields::edit_string( :title, save_admin_article_path( row.id ) ) + div row.title, ActiveAdmin::DynamicFields.edit_string(:title, save_admin_article_path(row.id)) end # Edit a boolean: column :published do |row| - status_tag row.published, ActiveAdmin::DynamicFields::edit_boolean( :published, save_admin_article_path( row.id ), row.published ) + status_tag row.published, ActiveAdmin::DynamicFields.edit_boolean(:published, save_admin_article_path(row.id), row.published) end # Edit a select ([''] allow to have a blank value): column :author do |row| - select ActiveAdmin::DynamicFields::edit_select( :author_id, save_admin_article_path( row.id ) ) do - options_for_select( [''] + Author.pluck( :name, :id ), row.author_id ) + select ActiveAdmin::DynamicFields.edit_select(:author_id, save_admin_article_path(row.id)) do + options_for_select([''] + Author.pluck(:name, :id), row.author_id) end end ``` -- In *show* config (less useful): +- In *show* config (inside `attributes_table` block): ```rb row :title do |row| - div row.title, ActiveAdmin::DynamicFields::edit_string( :title, save_admin_article_path( row.id ) ) + div row.title, ActiveAdmin::DynamicFields.edit_string(:title, save_admin_article_path(row.id)) end ``` ### Dialog example @@ -148,16 +148,20 @@ ```rb ActiveAdmin.register Author do # ... member_action :dialog do - content = '<dl style="margin: 12px">' - [:name, :age, :created_at].each do |field| - content += "<dt>#{Author.human_attribute_name(field)}:</dt><dd>#{resource[field]}</dd>" + record = resource + context = Arbre::Context.new do + dl do + %i[name age created_at].each do |field| + dt "#{Author.human_attribute_name(field)}:" + dd record[field] + end + end end - content += '</dl>' - render plain: content + render plain: context end # ... end ``` @@ -168,11 +172,11 @@ # ... show do |object| attributes_table do # ... row :author do - link_to object.author.name, dialog_admin_author_path( object.author ), title: object.author.name, 'data-df-dialog': true, 'data-df-icon': true + link_to object.author.name, dialog_admin_author_path(object.author), title: object.author.name, 'data-df-dialog': true, 'data-df-icon': true end end end # ... end @@ -186,10 +190,10 @@ Take a look at [other ActiveAdmin components](https://github.com/blocknotes?utf8=✓&tab=repositories&q=activeadmin&type=source) that I made if you are curious. ## Contributors -- [Mattia Roccoberton](http://blocknot.es) - creator, maintainer +- [Mattia Roccoberton](http://blocknot.es): author ## License [MIT](LICENSE.txt)