Skip to content

Instantly share code, notes, and snippets.

@ascsystems
Last active December 20, 2015 08:19
Show Gist options
  • Select an option

  • Save ascsystems/6099689 to your computer and use it in GitHub Desktop.

Select an option

Save ascsystems/6099689 to your computer and use it in GitHub Desktop.
class ProductImage < ActiveRecord::Base
attr_accessible :name, :product_id, :path
belongs_to :product
has_many :product_option_value_images
has_many :product_option_values, through: :product_option_value_images
def getImage(options)
if(options.empty? == false)
image = ProductImage.joins(:product_option_values).where(product_option_values: { id: options })
image
end
end
end
class ProductOptionValue < ActiveRecord::Base
attr_accessible :option_value_id, :price, :product_id
belongs_to :product
belongs_to :option_value
end
class ProductOptionValueImage < ActiveRecord::Base
attr_accessible :product_image_id, :product_option_value_id
belongs_to :product_option_value
belongs_to :product_image
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment