Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

activeadmin_settings_cached

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

activeadmin_settings_cached

  • 2.3.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Activeadmin Settings Cached

Gem Version Build Status Dependency Status Coverage Status

Provides a nice UI interface for rails-settings-cached gem in Active Admin.

Installation

Add this line to your application's Gemfile:

gem 'activeadmin_settings_cached'

And then execute:

$ bundle

Create your settings model:

$ rails g settings:install
$ bundle exec rake db:migrate

Create your settings page:

# From generators                   
$ rails g active_admin:settings Setting  
             
# Or manual
# app/admin/setting.rb
ActiveAdmin.register_page 'Setting' do
  title = 'Settings'
  menu label: title

  active_admin_settings_page(
    title: title
  )
end

And configure your default values in your Settings model:

class Settings < RailsSettings::CachedSettings
  defaults[:my_awesome_settings] = 'This is my settings'
end

In your application's admin interface, there will now be a new page with this setting

active_admin_settings_page DSL

Basic usage
ActiveAdmin.register_page 'Settings' do
  menu label: 'Settings', priority: 99
  active_admin_settings_page options
end
Options
ToolDescription
:model_nameString, settings model name override (default: uses name from global config.)
:starting_withString, each key must starting with, (default: nil)
:keyString, Symbol root key, can be replacement for starting_with, (default: nil)
:templateString, custom template rendering (default: 'admin/settings/index')
:template_objectobject passing to view (default: ActiveadminSettingsCached::Model instance)
:displayHash, display settings override (default: {})
:titleString, title value override (default: I18n.t('settings.menu.label'))
:after_saveProc, callback for action after POST request, (default: nil)

Localization

You can localize settings keys in local file

en:
  settings:
    attributes:
      my_awesome_settings: 'My Awesome Localized Setting'

Model name

By default the name of the mode is Setting. If you want to use a different name for the model, you can specify your that in config/initializers/active_admin_settings_cached.rb:

ActiveadminSettingsCached.configure do |config|
  config.model_name = 'AdvancedSetting'
end

Display options

If you need define display options for settings fields, eg textarea, url or :timestamp and etc., you can set display option in initializer.

ActiveadminSettingsCached.configure do |config|
  config.display = {
    my_awesome_setting_name: :text,
    my_awesome_setting_name_2: :timestamp,
    my_awesome_setting_name_3: :select
  }
end

Available options see here

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

FAQs

Package last updated on 22 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc