Skip to content

Instantly share code, notes, and snippets.

@omarqureshi
Created April 28, 2010 14:58
Show Gist options
  • Save omarqureshi/382254 to your computer and use it in GitHub Desktop.
Save omarqureshi/382254 to your computer and use it in GitHub Desktop.
Index: app/models/content.rb
===================================================================
--- app/models/content.rb (revision 17155)
+++ app/models/content.rb (working copy)
@@ -83,6 +83,16 @@
end
end
+ named_scope :another_extract, lambda { |reading_level| {:include => [{:content_items => :reading_level}], :conditions => ["reading_levels.tag = ?", reading_level || 'unknown']}}
+ named_scope :another_recipe, lambda { |recipe| {:include => :recipe, :conditions => ["recipes.tag = ?", recipe]}}
+
+ def method_missing(method_name, *args)
+ @extracted_content_items ||= self.content_items.all(:include => :ingredient).each do |ci|
+ self[ci.ingredient.tag] = Content.tovalue(ci.ingredient.datatype, ci.content_str)
+ end
+ self[method_name]
+ end
+
def reviewable_type; "Content"; end
include Reviewable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment