ActiveAdmin.register <%= module_camel %>::<%= resource_camel %> do menu :label => "<%= menu_name %>" config.per_page = 30 form do |f| f.semantic_errors # shows errors on :base #f.inputs # builds an input field for every attribute f.inputs do f.input :id <% attributes.each do |pair| %><% field = pair.split(":")[0] %> f.input :<%= field %> <% end %> f.input :updated_at f.input :created_at end f.actions # adds the 'Submit' and 'Cancel' buttons end controller do def create @<%= resource_singular %> = ::<%= module_camel %>::V<%= api_version %>::<%= resource_camel %>.new(<%= resource_singular %>_params) if @<%= resource_singular %>.save flash[:notice] = "Created Successfully!" redirect_to resource_path @<%= resource_singular %> else flash[:notice] = "#{@<%= resource_singular %>.errors.full_messages}" redirect_to new_resource_path @<%= resource_singular %> #super #render :new end end def update @<%= resource_singular %> = ::<%= module_camel %>::V<%= api_version %>::<%= resource_camel %>.find(params[:id]) if @<%= resource_singular %>.update(<%= resource_singular %>_params) flash[:notice] = "Updated Successfully!" redirect_to resource_path @<%= resource_singular %> else flash.now[:notice] = "#{@<%= resource_singular %>.errors.full_messages}" render :edit #super end end def destroy @<%= resource_singular %> = ::<%= module_camel %>::V<%= api_version %>::<%= resource_camel %>.find(params[:id]) @<%= resource_singular %>.destroy flash.now[:notice] = "Deleted Successfully!" render :index end private def <%= resource_singular %>_params params.require(:<%= resource_singular %>).permit(<%= params_list %>) end end index do column :id <% attributes.each do |pair| %><% field = pair.split(":")[0] %> column :<%= field %> <% end %> column :updated_at column :created_at actions end show do attributes_table do row :id <% attributes.each do |pair| %><% field = pair.split(":")[0] %> row :<%= field %> <% end %> row :updated_at row :created_at end end # See permitted parameters documentation: # https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters # # permit_params :list, :of, :attributes, :on, :model # # or # # permit_params do # permitted = [:permitted, :attributes] # permitted << :other if resource.something? # permitted # end end