Project

realiser

0.0
No commit activity in last 3 years
No release in over 3 years
Rails engine that you can use when you need dynamic setting data to your app
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 6.1.3, >= 6.1.3.2
 Project Readme

Realiser

The Rails engine will help you to provides the setting data to your app. See the demo engine in here.

Installation

Add this line to your application's Gemfile:

gem 'realiser'

And then execute:

$ bundle

Or install it yourself as:

$ gem install realiser

After that, run this command to generate the migration files:

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

Then, you can enable the Web UI, with mount the engine in your config/routes.rb:

Rails.application.routes.draw do
  mount Realiser::Engine => '/realiser'
end

Then, add this line to your app/assets/config/manifest.js to help compile the stylesheets.

//= link realiser/application.css

Done, you can manage the settings data by visiting the path /realiser.

The UI will be something like this:

preview

Usage

You can access your setting by calling them like this:

Realiser::Setting['PAYMENT_TOKEN'] #> 'sgFadLoRx5rX1VL02OalMQ' 

Honesly, the Realiser::Setting object is inherit from ActiveRecord::Base, so you can also show the value with something like this:

Realiser::Setting.find_by(key: 'PAYMENT_TOKEN').value #> 'sgFadLoRx5rX1VL02OalMQ' 

By inheriting the object with the active record object, I hope you can more flexible when want to use the setting object.

If you thing Realiser::Setting is too long, you can also make them short with creating new class like this:

# app/models/setting.rb
class Setting < Realiser::Setting
end

So can use like this:

Setting['PAYMENT_TOKEN'] #> 'sgFadLoRx5rX1VL02OalMQ' 

Contributing

PR are welcome!

You can use the issue tab for asking me a question about this engine, or report a bug, or even to request a feature.

License

The gem is available as open source under the terms of the MIT License.