Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Image < ActiveRecord::Base
- has_many :custom_fields
- # has a name column
- end
- class CustomField < ActiveRecord::Base
- belongs_to :field, :polymorphic => true
- # has only IDs
- end
- class StringField < ActiveRecord::Base
- has_one :custom_field, :as => :field
- # has a value column
- end
- Image.find(:join => {:custom_fields=>:field}, :conditions => {"custom_fields.name"=>name, "custom_fields.field.value"=>value})
Add Comment
Please, Sign In to add comment