Skip to content

Instantly share code, notes, and snippets.

@Preacher
Preacher / channel.rb
Created February 5, 2012 13:50
Auto-creating & updating child element in has_many relationship
class Channel < ActiveRecord::Base
attr_accessible :private, :title, :color_code, :subscriptions_attributes
validates_presence_of :user, :title
after_save :add_owner
belongs_to :user
has_many :subscriptions, :inverse_of => :channel, :dependent => :destroy
has_many :users, :through => :subscriptions, :uniq => true
accepts_nested_attributes_for :subscriptions, :allow_destroy => true
@Preacher
Preacher / doc head
Created July 15, 2011 11:22
IE is crap
<!--[if lte IE 8]>
<meta http-equiv="refresh" content="0; url=/ie_unsupported.html" />
<script type="text/javascript">
/* <![CDATA[ */
window.top.location = '/ie_unsupported.html';
/* ]]> */
</script>
<![endif]-->
@Preacher
Preacher / main.conf
Created June 28, 2011 20:52
Wedding/Coding sites apache conf
<VirtualHost *:80>
ServerAdmin david.stites@afewguyscoding.com
ServerName afewguyscoding.com
ServerAlias www.afewguyscoding.com, davidstites.com, www.davidstites.com, 5280software.com, www.5280software.com, milehigh-software.com, www.milehigh-software.com, milehighsoftware.org, www.milehighsoftware.org,
# this tells rails that it will run in production mode
# this is for rails < 3.x
RailsEnv production
DocumentRoot /var/www/afewguyscoding/current/public
@Preacher
Preacher / application.js
Created May 18, 2011 18:25
paginated ability to add photos to articles via habtm association - lacks ability to select photos from multiple galleries
$(document).ready(function() {
// ...
$('.selector_control').live('click', function() {
$(this).parents('.select_galleries').find('.select_photos').slideToggle();
});
$('.all_photos').click(function(){
$(this).closest('.select_galleries').find("INPUT[type='checkbox']").attr('checked', true);
});