public
Rubygem
Description: A tagging plugin for Rails applications that allows for custom tagging along dynamic contexts.
Homepage: http://mbleigh.lighthouseapp.com/projects/10116-acts-as-taggable-on
Clone URL: git://github.com/mbleigh/acts-as-taggable-on.git
Click here to lend your support to: acts-as-taggable-on and make a donation at www.pledgie.com !
Another Sinclair Bain patch! This time it lets taggers create new contexts on 
the fly. [#19 status:resolved]
mbleigh (author)
Fri Jun 13 06:10:09 -0700 2008
commit  f36efe70ff7e78180104f3bedc99430df7c6e9cc
tree    f45b72032359ddc088b4a47344f80905111e5edc
parent  b9b62566de1861dc111cc3ab96d49a39a2d86457
...
24
25
26
 
 
27
28
29
30
 
 
 
31
32
33
...
24
25
26
27
28
29
30
31
 
32
33
34
35
36
37
0
@@ -24,10 +24,14 @@ module ActiveRecord
0
         end
0
         
0
         def tag(taggable, opts={})
0
+          opts.reverse_merge!(:force => true)
0
+
0
           return false unless taggable.respond_to?(:is_taggable?) && taggable.is_taggable?
0
           raise "You need to specify a tag context using :on" unless opts.has_key?(:on)
0
           raise "You need to specify some tags using :with" unless opts.has_key?(:with)
0
-          raise "No context :#{opts[:on]} defined in #{taggable.class.to_s}" unless taggable.tag_types.include?(opts[:on])
0
+          raise "No context :#{opts[:on]} defined in #{taggable.class.to_s}" unless 
0
+              ( opts[:force] || taggable.tag_types.include?(opts[:on]) )
0
+
0
           taggable.set_tag_list_on(opts[:on].to_s, opts[:with], self)
0
           taggable.save
0
         end
...
1
2
 
 
 
 
3
4
5
...
1
2
3
4
5
6
7
8
9
0
@@ -1,5 +1,9 @@
0
 require File.dirname(__FILE__) + '/../../../../spec/spec_helper'
0
 
0
+module Spec::Example::ExampleGroupMethods
0
+  alias :context :describe
0
+end
0
+
0
 plugin_spec_dir = File.dirname(__FILE__)
0
 ActiveRecord::Base.logger = Logger.new(plugin_spec_dir + "/debug.log")
0
 

Comments