Quantcast
Channel: Best way to create custom config options for my Rails app? - Stack Overflow
Browsing latest articles
Browse All 15 View Live

Answer by Marcelo Austria for Best way to create custom config options for my...

My best way to custom config, with raise message when setting.yml is missing.gets loaded from a custom initializer in config/initializers/custom_config.rbsetting_config =...

View Article



Answer by greenif for Best way to create custom config options for my Rails app?

My way to load Settings before Rails initializeAllows you to use settings in Rails initialization and configure settings per environment# config/application.rbBundler.require(*Rails.groups)mode =...

View Article

Answer by Ali MasudianPour for Best way to create custom config options for...

Rails >= 4.2Just create a YAML file into config/ directory, for example: config/neo4j.yml.Content of neo4j.yml can be somthing like below(For simplicity, I used default for all...

View Article

Answer by Kitebuggy for Best way to create custom config options for my Rails...

Building on Omer Aslam's elegant solution, I decided to convert the keys into symbols. The only change is:all_config = YAML.load_file("#{Rails.root}/config/config.yml").with_indifferent_access ||...

View Article

Answer by skilleo for Best way to create custom config options for my Rails app?

Rails 4To create a custom configuration yaml and load it (and make available to your app) similar to how database_configuration.Create your *.yml, in my case I needed a redis configuration...

View Article


Answer by smathy for Best way to create custom config options for my Rails app?

I just wanted to update this for the latest cool stuff in Rails 4.2 and 5, you can now do this inside any of your config/**/*.rb files:config.x.whatever = 42(and that's a literal x in there, ie. the...

View Article

Answer by 6ft Dan for Best way to create custom config options for my Rails app?

I prefer accessing settings through the global application stack. I avoid excess global variables in local...

View Article

Answer by Omer Aslam for Best way to create custom config options for my...

Step 1: Create config/initializers/appconfig.rb require 'ostruct'require 'yaml'all_config = YAML.load_file("#{Rails.root}/config/config.yml") || {}env_config = all_config[Rails.env] || {}AppConfig =...

View Article


Answer by foomip for Best way to create custom config options for my Rails app?

Just some extra info on this topic:APP_CONFIG = YAML.load_file(Rails.root.join('config', 'config.yml'))[Rails.env].with_indifferent_access".with_indifferent_access" allows you to access the values in...

View Article


Answer by Jack Chu for Best way to create custom config options for my Rails...

I use something similar to John for Rails 3.0/3.1, but I have erb parse the file first:APP_CONFIG = YAML.load(ERB.new(File.new(File.expand_path('../config.yml', __FILE__)).read).result)[Rails.env]This...

View Article

Answer by David Burrows for Best way to create custom config options for my...

Rails 3 version of initialiser code is as follows (RAILS_ROOT & RAILS_ENV are deprecated)APP_CONFIG = YAML.load_file(Rails.root.join('config', 'config.yml'))[Rails.env]Also, Ruby 1.9.3 uses Psych...

View Article

Answer by Straff for Best way to create custom config options for my Rails app?

see my response to Where is the best place to store application parameters : database, file, code...?A variation to what you had in that it's a simple reference to another file. It sees that...

View Article

Answer by Jerry Cheung for Best way to create custom config options for my...

I like simpleconfig. It allows you to have per environment configuration.

View Article


Answer by John Topley for Best way to create custom config options for my...

For general application configuration that doesn't need to be stored in a database table, I like to create a config.yml file within the config directory. For your example, it might look like...

View Article

Best way to create custom config options for my Rails app?

I need to create one config option for my Rails application. It can be the same for all environments. I found that if I set it in environment.rb, it's available in my views, which is exactly what I...

View Article

Browsing latest articles
Browse All 15 View Live




Latest Images