active admin CRUD for app feature

This commit is contained in:
Nuwan 2024-07-17 15:27:50 +05:30
parent 86d77df2c9
commit 041ebccaf1
2 changed files with 33 additions and 7 deletions

View File

@ -0,0 +1,21 @@
ActiveAdmin.register JamRuby::AppFeature, as: 'App Features' do
menu parent: 'Misc', label: 'App Features'
config.sort_order = 'created_at ASC'
config.batch_actions = false
config.filters = false
config.per_page = 50
config.paginate = true
form do |f|
f.inputs 'Fields' do
f.input(:feature_type, as: :select, collection: JamRuby::AppFeature::FEATURE_TYPES)
f.input(:handle, :input_html => { :maxlength => 1025 })
f.input(:is_enabled, as: :boolean)
f.input(:env, as: :select, collection: %w(production staging development))
end
f.actions
end
end

View File

@ -1,8 +1,13 @@
module JamRuby
class AppFeature < ActiveRecord::Base
self.primary_key = 'id'
self.table_name = 'app_features'
class JamRuby::AppFeature < ActiveRecord::Base
attr_accessible :feature_type, :handle, :is_enabled, :env
end
FEATURE_TYPES = %w(page)
attr_accessible :feature_type, :handle, :is_enabled, :env, as: :admin
#self.table_name = 'app_features'
validates :feature_type, presence: true, inclusion: {in: FEATURE_TYPES}
validates :handle, presence: true, length: {maximum: 255}
validates :is_enabled, inclusion: {in: [true, false]}
validates :env, presence: true, inclusion: {in: %w(production staging development)}
end