class <%= @class_scope.present? ? "#{@class_scope}::" : '' %><%= @plural_model_name %>Controller < <%= @controller_base %> include DynamicScaffold::Controller dynamic_scaffold <%= @model_name %> do |config| # If you want to use all views common variables, please call `vars`. # Please see https://github.com/gomo/dynamic_scaffold#view-helper for details. # In your view: # <%%= dynamic_scaffold.vars.scope_target.name %> # here: # config.vars :scope_target do # SomeRecord.find(params['some_record_id']) # end # You can get the current page title like `Country List`, `Edit Country` in your view. # <%%= dynamic_scaffold.title.current.full %> # If you want change from the model name, set config.title.name. # Please see https://github.com/gomo/dynamic_scaffold#view-helper for details. # config.title.name = 'Model' # To enable scoping, call scope with parameter names you want. # Please see https://github.com/gomo/dynamic_scaffold#scoping for details. # config.scope([role]) # You can specify the maximum count of registrations. # Please see https://github.com/gomo/dynamic_scaffold#limit-count for details. # config.max_count 10 # When you want a simple sort on the column of record, please call order. # config.list.order created_at: :desc # To enable sorting, call sorter method specifying the column name and direction. # config.list.sorter sequence: :desc # To enable pagination, call pagination. All args is not require, defauls is below # config.list.pagination( # per_page: 25, # window: 0, # kaminari options # outer_window: 0, # kaminari options # left: 0, # kaminari options # right: 0, # kaminari options # param_name: :page, # kaminari options # total_count: true, # Whether to display total count on active page like `2 / 102` # end_buttons: true, # Whether to display buttons to the first and last page. # neighbor_buttons: true, # Whether to display buttons to the next and prev page. # gap_buttons: false, # Whether to display gap buttons. # highlight_current: false, # Whether to highlight the current page. # ) # If you want filtering that can not be handled by `config.scope`, you can use the filter method. # config.list.filter do |query| # query.where(parent_id: nil) # end # You can set each title in the list header through title method. # Pass the attribute name, # config.list.title(:name) # or # config.list.title do |record| # record.name # end # You can change the items displayed in the list through the `config.list.item`. # Please see https://github.com/gomo/dynamic_scaffold#customize-list for details. <%- @model.column_names.each do |column| -%> config.list.item(:<%= column %>, class: 'ds-auto-width') <%- end -%> # You can customize the form fields through `config.form`. # Please see https://github.com/gomo/dynamic_scaffold#customize-form for details. <%- @model.column_names.select{|c| c != @model.primary_key}.each do |column| -%> config.form.item(:text_field, :<%= column %>) <%- end -%> end # def index # super do |query| # # If you want to add a search to the page, please add it to the query here. # # The condition added here does not affect max_count. # # Please note that returning nil will be ignored. # end # end # def new # super # end # def edit # super # end # def create # super do |record| # # If you want to modify the attributes of the record before saving, Write here. # end # end # def update # super do |record, prev_attribute| # # If you want to modify the attributes of the record before saving, Write here. # end # end # def destroy # super # end # def sort # super # end end