Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
A Rails Engine to manage your application settings. Includes validation. Compatible with Rails 5. It compatible with rails-settings-cached gem.
Preview:
Live example: http://rails-settings-ui.herokuapp.com/
Add to Gemfile
gem 'rails-settings-ui'
then add
gem 'rails-settings-cached'
or
gem 'rails-settings'
or your fork of rails-settings.
If you want to use bootstrap interface you need also include bootstrap stylesheets to your app. You may use bootstrap-sass gem for that.
Setup:
# adds initializer and route:
rails g rails_settings_ui:install
In config/initializers/rails_settings_ui.rb
RailsSettingsUi.setup do |config|
config.ignored_settings = [:company_name] # Settings not displayed in the interface
config.settings_class = "MySettings" # Customize settings class name
config.settings_displayed_as_select_tag = [:mode] # Settings displayed as select tag instead of checkbox group field
config.defaults_for_settings = {mode: :manual} # Default option values for select tags
config.engine_name = "your engine name" # Default use 'main_app', if you mount this engine to another engine, then set name of engine
end
# engine root:
rails_settings_ui_url
You can localize:
settings:
attributes:
launch_mode: # setting name
name: 'Launch mode'
settings:
attributes:
launch_mode:
labels:
auto: 'Auto mode'
manual: 'Manual mode'
settings:
attributes:
buy_mode:
labels:
auto: 'Auto buy' # 'auto' is option value, 'Auto buy' is option label
manual: 'Manual buy'
so result will be:
<option value="auto">Auto buy</option>
<option value="manual">Manual buy</option>
if you don't specify labels in locale config, you'll get:
<option value="auto">auto</option>
<option value="manual">manual</option>
settings:
attributes:
launch_mode:
help_block: 'Rocket launch mode'
To validation work is required the default settings in the proper format, eg:
For rails-settings-cached up to 0.5.8:
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
For rails-settings-cached with version >= 0.6.0 default settings moved to YAML config file (config/app.yml), so defaults should looks like:
defaults: &defaults
rocket_name: "Foo"
limit: 123
launch_mode:
- auto
- manual
spaceports:
- plesetsk
- baikonur
style:
border_color: 'e0e0e0'
block_color: 'ffffff'
title:
font: "Tahoma"
size: "12"
color: '107821'
development:
<<: *defaults
test:
<<: *defaults
production:
<<: *defaults
Default layout is application
, but you can render all rails-settings-ui views inside your app layout
(for nice looking you will need include bootstrap, eg: @import 'bootstrap';
in your applications.css.scss):
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_engine_routes! # old name of method inline_main_app_routes!
end
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 # for Rails 3
before_action :check_settings_permissions # starting from Rails 4
private
def check_settings_permissions
render status: 403 unless current_user && can_manage_settings?(current_user)
end
end
end
RailsSettingsUi::ApplicationController
, you must call helpers for main_app
, for example: main_app.root_path
This project uses MIT-LICENSE.
FAQs
Unknown package
We found that rails-settings-ui demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.