Bizarroids Settings¶ ↑
Flexible settings for Rails application. This is a part of The Bizarroids.
Installation¶ ↑
Add it to your Gemfile:
gem 'bizarroids_settings'
Run the following command to install it:
bundle install
Run the generator:
rails generate bizarroids:settings:install
Configuraton¶ ↑
Edit config/initialisers/bizarroids_settings.rb
. You can create options using folowing syntax:
config.option :key, :string, value: 'MyString', other: :options
Avaliable types:
-
string
-
integer
-
float
-
boolean
-
text
-
date
-
datetime
-
file
Avaliable options:
-
name - gives user readable name to the option. It would be show in admin panel.
-
description - description to show in admin panel.
-
require - if set true, prevents user to set empty value.
-
hidden - if set true, hides option from user in admin panel.
-
collection - (+collection: [1, 2, 3]+) forses user to select given values instead of enter in input field.
Some additional configuration can be found config/initialisers/bizarroids_settings.rb
Usage¶ ↑
Link for admin panel
bizarroids_settings_menu_link
If you use cancancan place in your ability.rb somthing like
can :manage, Bizarroids::Settings::Option
if don’t, place in config/initialisers/bizarroids_settings.rb
config.use_cancancan = false
To get value for :key
Get:
Bizarroids::Settings.get(:key) Bizarroids::Settings[:key]
Set:
Bizarroids::Settings.get(:key) = 'my value' Bizarroids::Settings[:key] = 'my value'
TODO¶ ↑
-
image styles for file field
-
Tests
This project rocks and uses MIT-LICENSE.