Skip to content

Instantly share code, notes, and snippets.

@benphelps
Created August 29, 2012 03:48
Show Gist options
  • Save benphelps/3506610 to your computer and use it in GitHub Desktop.
Save benphelps/3506610 to your computer and use it in GitHub Desktop.
class Armor < ActiveRecord::Base
attr_accessible :back_id, :character_id, :chest_id, :feet_id, :hands_id, :head_id, :legs_id, :shoulder_id, :waist_id, :finger_id
belongs_to :character
[:back, :chest, :feet, :hands, :head, :legs, :shoulder, :waist, :finger].each do |part|
belongs_to part, :class_name => 'ArmorItem'
define_method part do
# what do I place here? I'm using :class_name to route it to an ArmorItem
ArmorItem.find(:part[_id])
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment