Created
August 29, 2012 01:33
-
-
Save benphelps/3505918 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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 | |
attr_reader :back, :chest, :feet, :hands, :head, :legs, :shoulder, :waist, :finger | |
## This isn't very dry, perhaps there is a better method? | |
def hands | |
ArmorItem.find(hands_id).name | |
end | |
belongs_to :back, :class_name => 'ArmorItem' | |
belongs_to :chest, :class_name => 'ArmorItem' | |
belongs_to :feet, :class_name => 'ArmorItem' | |
belongs_to :hands, :class_name => 'ArmorItem' | |
belongs_to :head, :class_name => 'ArmorItem' | |
belongs_to :legs, :class_name => 'ArmorItem' | |
belongs_to :shoulder, :class_name => 'ArmorItem' | |
belongs_to :waist, :class_name => 'ArmorItem' | |
belongs_to :finger, :class_name => 'ArmorItem' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment