Sha256: d3ab5e4c84a3e1726f0bef8f2a5c12de1727d3d2d894cd7c355bd731d26bab81
Contents?: true
Size: 1.39 KB
Versions: 3
Compression:
Stored size: 1.39 KB
Contents
module SimpleAdmin module ResourceController module DynamicFields # Concern that include methods for getting entity and entity fields # Working together with ResourceCrud # @example PostsController with ResourceCrud and ResourceFields # class PostsController # include ResourceController::Crudify # include SimpleAdmin::ResourceFields # # ... # end # @since 0.1.0 extend ActiveSupport::Concern included do before_action :initialize_fields_entities! # Receives entity and entity fields by model class and field_presentation # # @since 0.1.0 def initialize_fields_entities! @entity = SimpleAdmin::Entity.find_by(model_klass_name: model_klass.to_s) @entity_fields = @entity.entity_fields.where(presentation: field_presentation) end private def field_presentation case params[:action] when 'index' :collection when 'new' :form when 'create' :form when 'edit' :form end end def resource_params_name model_klass.model_name.singular end def resource_attributes SimpleAdmin::Entity.form_attributes(model_klass) end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems