lib/reviewed/article.rb in reviewed-0.2.2 vs lib/reviewed/article.rb in reviewed-0.4.0
- old
+ new
@@ -3,13 +3,15 @@
require 'reviewed/attachment'
require 'reviewed/deal'
module Reviewed
class Article < Base
+
+ has_attachments
+
has_many :pages
has_many :products
- has_many :attachments
has_many :deals
has_many :related_articles, class_name: "Reviewed::Article"
def find_page(slug)
pages.find { |page| page.slug.match(/#{slug}/i) }
@@ -19,17 +21,7 @@
if respond_to?(:products)
products.select { |p| p.id == primary_product_id }.first
end
end
- def attachments(tag=nil)
- if tag.present?
- @attributes.attachments.select do |attachment|
- attachment_tags = attachment.tags || []
- attachment_tags.map(&:downcase).include?(tag.downcase)
- end
- else
- @attributes.attachments
- end
- end
end
end