Skip to content

Instantly share code, notes, and snippets.

@between40and2
Last active August 29, 2015 14:02
Show Gist options
  • Save between40and2/a02495c613576f83e394 to your computer and use it in GitHub Desktop.
Save between40and2/a02495c613576f83e394 to your computer and use it in GitHub Desktop.
This is enlightened by ...

Rails Initializers

Be sure to restart your server when you modify this file.

backtrace_silencers.rb

You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.

# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }

You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.

# Rails.backtrace_cleaner.remove_silencers!

filter_parameter_logging.rb

# Configure sensitive parameters which will be filtered from the log file.
Rails.application.config.filter_parameters += [:password]

inflections.rb

Add new inflection rules using the following format. Inflections are locale specific, and you may define rules for as many different locales as you wish. All of these examples are active by default:

# ActiveSupport::Inflector.inflections(:en) do |inflect|
#   inflect.plural /^(ox)$/i, '\1en'
#   inflect.singular /^(ox)en/i, '\1'
#   inflect.irregular 'person', 'people'
#   inflect.uncountable %w( fish sheep )
# end   
    
# These inflection rules are supported but not enabled by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
#   inflect.acronym 'RESTful'
# end

mime_types.rb

# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone

secret_token.rb

Your secret key is used for verifying the integrity of signed cookies.
If you change this key, all old signed cookies will become invalid!

Make sure the secret is at least 30 characters and all random, no regular words or you'll be exposed to dictionary attacks. You can use rake secret to generate a secure secret key.

# Make sure your secret_key_base is kept private
# if you're sharing your code publicly.
Slcc::Application.config.secret_key_base = '2054707dab6d8d9266******'

session_store.rb

Slcc::Application.config.session_store :cookie_store, key: '_slcc_session'

wrap_parameters.rb

This file contains settings for ActionController::ParamsWrapper which is enabled by default.

# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
    wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
end

To enable root element in JSON for ActiveRecord objects.

# ActiveSupport.on_load(:active_record) do
#  self.include_root_in_json = true
# end

Refs

i

bold

The End

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment