Skip to content

Instantly share code, notes, and snippets.

View jfeust's full-sized avatar

John Feustel jfeust

View GitHub Profile
@jfeust
jfeust / rails_association_id_cleanup.rb
Created August 11, 2011 18:20
Rails Association Id Cleanup On Destroy
# I found a bit of odd rails behavior recently. Consider the following classes.
class Contact < ActiveRecord::Base
belongs_to :gallery
end
class Gallery < ActiveRecord::Base
has_many :contacts
end
@jfeust
jfeust / gist:1114917
Created July 29, 2011 22:49
Ruby Style Guide
Original Source: https://github.com/chneukirchen/styleguide
= Christian Neukirchen's Ruby Style Guide
You may not like all rules presented here, but they work very well for
me and have helped producing high quality code. Everyone is free to
code however they want, write and follow their own style guides, but
when you contribute to my code, please follow these rules:
@jfeust
jfeust / README.md
Created July 5, 2011 00:11 — forked from napcs/README.md
Deploying Rails to Linode

Deploying Rails to Linode

Installing Ruby Enterprise Edition, Apache, MySQL, and Passenger for deploying Rails 3.0 applications.

Get a Linode, and set it up with Ubuntu 10.04 LTS so that you have till April 2013 to get updates. Once the Linode is formatted, boot it and continue on.

Set up an 'A' record in your DNS, pointing to the IP of your Linode. I'm using demo.napcs.com here.

Initial setup

@jfeust
jfeust / mock_image_table_prawn.rb
Last active July 13, 2021 21:28
Mock Table with Images in Prawn
# NOTE: Prawn 1.0 now supports images in tables, and it works much better than my mock table below!
# As you may have noticed Prawn does not currently support images in table cells.
# There is an unofficial fork with initial table image support but it appears that
# it will be some time before this gets merged into the official branch.
#
# Instead of using an unofficial branch, I found a nice way to do a mock table with
# image support. You just need to keep track of your page breaks.
@jfeust
jfeust / gist:946426
Created April 28, 2011 14:17
Polymorphic Question
class Picture < ActiveRecord::Base
belongs_to :imageable, :polymorphic => true
end
class Employee < ActiveRecord::Base
has_many :pictures, :as => :imageable
end
class Product < ActiveRecord::Base
has_many :pictures, :as => :imageable