Created
May 23, 2013 09:29
-
-
Save yorzi/5634915 to your computer and use it in GitHub Desktop.
Some useful initialisers for Rails projects.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# don't generate RSpec tests for views and helpers by default | |
Rails.application.config.generators do |g| | |
g.view_specs false | |
g.helper_specs false | |
g.stylesheets false | |
g.helper false | |
g.javascripts false | |
g.template_engine :haml | |
g.form_builder :simple_form | |
g.test_framework :rspec, fixture: true, view_specs: false | |
g.fixture_replacement :factory_girl, dir: "spec/factories" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Logger::SimpleFormatter | |
# from activesupport/lib/active_support/core_ext/logger.rb | |
def call(severity, time, progname, msg) | |
"#{severity_color severity} #{String === msg ? msg : msg.inspect}\n" | |
end | |
private | |
def severity_color(severity) | |
case severity | |
when "WARN" | |
"\033[1;33;40m[WARNING]\033[0m" # bold yellow | |
when "INFO" | |
"\033[1;37;40m[INFO]\033[0m" # bold white | |
when "DEBUG" | |
"\033[0;34;40m[DEBUG]\033[0m" # blue | |
when "ERROR" | |
"\033[1;31;40m[ERROR]\033[0m" # bold red | |
when "FATAL" | |
"\033[7;31;40m[FATAL]\033[0m" # bold black, red bg | |
else | |
"[#{severity}]" # none | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActionMailer::Base.delivery_method = :smtp | |
ActionMailer::Base.smtp_settings = { | |
:address => "smtp.gmail.com", | |
:port => 587, | |
:domain => "gmail.com", | |
:user_name => "someone@gmail.com", | |
:password => "****", | |
:authentication => "plain", | |
:enable_starttls_auto => true | |
} | |
ActionMailer::Base.default_url_options[:host] = Setting.domain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "redis" | |
require "redis-namespace" | |
require "redis/objects" | |
redis_config = YAML.load_file("#{Rails.root}/config/redis.yml")[Rails.env] | |
Redis::Objects.redis = Redis.new(:host => redis_config['host'], :port => redis_config['port']) | |
sidekiq_url = "redis://#{redis_config['host']}:#{redis_config['port']}/0" | |
Sidekiq.configure_server do |config| | |
config.redis = { :namespace => 'sidekiq', :url => sidekiq_url } | |
end | |
Sidekiq.configure_client do |config| | |
config.redis = { :namespace => 'sidekiq', :url => sidekiq_url } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment