Giter VIP home page Giter VIP logo

rails-settings-ui's Introduction

PLEASE NOTE, THIS PROJECT IS NO LONGER BEING MAINTAINED

This project was moved to another location - https://github.com/accessd/rails-settings-ui

Rails settings UI

Gem Version Build Status

A Rails Engine to manage your application settings. Includes validation. Compatible with Rails 4. It compatible with rails-settings-cached gem. Untested, but should work with rails-settings gem.

Sponsored by Evrone

Demo

ScreenShot

Getting Started

Installation

Add to Gemfile

gem 'rails-settings-ui'
gem 'rails-settings-cached'
# or
gem 'rails-settings'
# or your fork of rails-settings

Setup:

# adds initializer and route:
rails g rails_settings_ui:install

Config

In config/initializers/rails_settings_ui.rb

RailsSettingsUi.setup do |config|
  config.ignored_settings = [:company_name] # Settings not displayed in the interface
end

Routing

# engine root:
rails_settings_ui_url

I18n

You can localize:

  • Settings names, eg:
  settings:
    attributes:
      launch_mode: # setting name
        name: 'Launch mode'
  • Checkbox options labels for array options, eg:
  settings:
    attributes:
      launch_mode:
        labels:
          auto: 'Auto mode'
          manual: 'Manual mode'
  • Select options labels and values(it's required for selects), eg:
  settings:
    attributes:
      buy_mode:
        labels:
          auto: 'Auto buy' # 'auto' is option value, 'Auto buy' is option label
          manual: 'Manual buy'
  • Help blocks for settings, eg:
  settings:
    attributes:
      launch_mode:
        help_block: 'Rocket launch mode'

Validations

To validation work is required the default settings in the proper format, eg:

class Settings < RailsSettings::CachedSettings
  defaults[:company_name] = "Company name"
  defaults[:head_name] = "Head name"
  defaults[:manager_premium] = 19
  defaults[:show_contract_fields] = true
  defaults[:launch_mode] = [:auto, :manual]
end

Views

Rails.application.config.to_prepare do
  # Use admin layout:
  RailsSettingsUi::ApplicationController.module_eval do
    layout 'admin'
  end
  # If you are using a custom layout, you will want to make app routes available to rails-setting-ui:
  RailsSettingsUi.inline_main_app_routes!
end

Authentication & authorization

You can specify the parent controller for settings controller, and it will inherit all before filters. Note that this must be placed before any other references to rails-setting-ui application controller in the initializer:

RailsSettingsUi.parent_controller = 'Admin::ApplicationController' # default: '::ApplicationController'

Alternatively, to have custom rules just for rails-setting-ui you can:

Rails.application.config.to_prepare do
  RailsSettingsUi::ApplicationController.module_eval do
    before_filter :check_settings_permissions
  
    private
    def check_settings_permissions
       render status: 403 unless current_user && can_manage_settings?(current_user)
    end
  end
end 

Contributing

Please read Code of Conduct and Contributing Guidelines for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Changelog

The changelog is here.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License.

rails-settings-ui's People

Contributors

accessd avatar stereodenis avatar

Stargazers

 avatar Iurii Gurzhii avatar Alexander Mescheryakov avatar Yaroslav Losev avatar Vladimir Vinnikov avatar Wadim Biekisz avatar Narek avatar Gosha Spark avatar Mikhail Dieterle avatar  avatar

Watchers

Alexander Balashov avatar Dmitry Galinsky avatar Andrey Voronkov avatar Oleg Balbekov avatar Ilya Belov avatar N S avatar Michael Mayorov avatar Dmitry Karpunin avatar Nickolay Yegorov avatar Pavel Argentov avatar Dafa avatar Stanislav Mekhonoshin avatar Miniwe avatar Александр Буртовой avatar  avatar Grachev Mikhail avatar Nikolay Ponomarev avatar James Cloos avatar Olga Novikova avatar Taras Haidamaka avatar Aleksei Zaitsev avatar  avatar Boris Kuznetsov avatar Dmitry avatar Aleksey Cherkasov avatar Dimmetrius avatar anoru avatar Alex Ermolaev avatar  avatar Kirill Volchenko avatar Max Sobkowski avatar Andrew Molchanov avatar Alexey Likhachev avatar Tema Nomad avatar Egor avatar  avatar Sergey avatar Eugene Zhukov avatar Nikita Skalkin avatar  avatar Demin.Sergey avatar Sergey Drogan avatar Ivan avatar Vadim Zakovriashin avatar  avatar Евгений Мазгалёв avatar Igor Vasilyev avatar Sergei Anenko avatar Alexander avatar Dmitry Ignatov avatar  avatar  avatar Mikhail Morgunov avatar  avatar WhiteMedusa avatar Dmitriy Dyakov avatar Kosivchenko Mikhail avatar Suleymanova Evgeniya avatar Albert avatar Andrey Aksenov avatar Marina Belova avatar Oleg avatar Oleg Nikitashin avatar  avatar

rails-settings-ui's Issues

undefined local variable or method `defaults' for #<Class:0xd521c48>

Hi,

When i try to add your gem in my project i get this error with the model "Setting.rb"

undefined local variable or method `defaults' for #Class:0xd521c48

class Setting < RailsSettings::CachedSettings
    defaults[:company_name] = "Test"
end

And this is my config/initializers/rails_settings_ui.rb

require 'rails-settings-ui'
Rails.application.config.to_prepare do
  RailsSettingsUi::ApplicationController.module_eval { layout 'administration' }

  # If you use a *custom layout*, make route helpers available to RailsSettingsUi:
  RailsSettingsUi.inline_main_app_routes!
end
RailsSettingsUi.settings_class = "Setting"

i'm not understand because this code work fine with an another project.

Thanks !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.