Skip to content

Instantly share code, notes, and snippets.

@lsemel
lsemel / MY_config.php
Created November 21, 2010 20:32
Vary configuration in CodeIgniter based on the the subdomain, e.g. (dev|staging|www).yourdomain.com
<?php
class MY_Config extends CI_Config {
/**
* Loads in custom server-specific configurations
*
* Additional config variables set
* server_name - the part of the hostname to the left of '.topleveldomain.com'
*
# in compass.rb
puts '>> Environment is ' + environment.to_s
if (environment.to_s == 'production')
puts '>> Disabling compass in production'
never_update = true
cache_location = '/tmp'
else
puts '>> Compass is enabled'
end
# This class gives you all the Rails 3 URL helpers, which are so
# unhelpfully unavailable in models, libraries, and unit tests
# Stick this in the library folder and get a URL with
# UrlHelpers.new.nameofmodel_url
class UrlHelpers
include Rails.application.routes.url_helpers
def initialize
default_url_options[:host] = case Rails.env
when "development" then "localhost"