From c763700c0a6ceae38a9241fd25af01dc14c8546c Mon Sep 17 00:00:00 2001 From: Daniel Collis-Puro Date: Wed, 28 Apr 2010 16:46:12 -0400 Subject: [PATCH] update acts_as_freetaggable --- .../20090526183152_create_tag_models.rb | 2 +- vendor/plugins/acts_as_category | 2 +- vendor/plugins/acts_as_freetaggable/README | 20 ----- vendor/plugins/acts_as_freetaggable/README.md | 76 +++++++++++++++++++ .../spec/fixtures/tags.yml | 47 ++++++++++++ vendor/plugins/has_many_polymorphs | 2 +- 6 files changed, 126 insertions(+), 23 deletions(-) delete mode 100644 vendor/plugins/acts_as_freetaggable/README create mode 100644 vendor/plugins/acts_as_freetaggable/README.md create mode 100644 vendor/plugins/acts_as_freetaggable/spec/fixtures/tags.yml diff --git a/db/migrate/20090526183152_create_tag_models.rb b/db/migrate/20090526183152_create_tag_models.rb index bd8e55a..75df923 100644 --- a/db/migrate/20090526183152_create_tag_models.rb +++ b/db/migrate/20090526183152_create_tag_models.rb @@ -16,7 +16,7 @@ def self.up end create_table :taggings do |t| - t.references :freetaggable, :polymorphic => true, :references => nil + t.references :freetaggable, :polymorphic => true t.references :tag t.timestamps end diff --git a/vendor/plugins/acts_as_category b/vendor/plugins/acts_as_category index db596af..5018a95 120000 --- a/vendor/plugins/acts_as_category +++ b/vendor/plugins/acts_as_category @@ -1 +1 @@ -acts_as_freetaggable/vendor/plugins/acts_as_category \ No newline at end of file +/home/djcp/rails/cohort/vendor/plugins/acts_as_freetaggable/vendor/plugins/acts_as_category \ No newline at end of file diff --git a/vendor/plugins/acts_as_freetaggable/README b/vendor/plugins/acts_as_freetaggable/README deleted file mode 100644 index f33ece7..0000000 --- a/vendor/plugins/acts_as_freetaggable/README +++ /dev/null @@ -1,20 +0,0 @@ -ActsAsFreetaggable -================== - -Introduction goes here. - - -Example -======= - -Example goes here. - -Testing -===== - -`rake freetaggable:specs` from RAILS_ROOT should work. At the moment -there is a bug where after a few successful test runs something mucks -up the inclusion of has_many_polymorphs and the tests won't run until -you reinstall the plugin - -Copyright (c) 2009 Ryan Neufeld, released under the MIT license diff --git a/vendor/plugins/acts_as_freetaggable/README.md b/vendor/plugins/acts_as_freetaggable/README.md new file mode 100644 index 0000000..167e6a0 --- /dev/null +++ b/vendor/plugins/acts_as_freetaggable/README.md @@ -0,0 +1,76 @@ +ActsAsFreetaggable +================== +About AAF +-------- +Acts as Freetaggable (AaF) aims to provide tagging to the models it decorates in a way unlike other tagging plugins provide. Where normal tagging plugins provide tagging in a flat model AaF provides tagging based on a hierarchical model. Take myself as an example: + +I belong in the Berkman Institutes hierarchy as an Intern, in a flat model I might be tagged as follows: + + (Berkman) (Intern) + +or + + (Berkman Intern) + +Add in `(Harvard)` as a parent to Berkman and I'd either need to be tagged, again, or have another tag created to represent that hierarchy. + +While this is OK for a few people, once you throw in 10s or 100s more tags and tagged objects things can quickly get out of hand. Drilling down a hierarchy objects need only be tagged once, by their deepest association. After this tagging has been made objects are by hierarchy tagged by all parents. + +Should I be tagged by the `(Harvard → Berkman → Intern)`'s `(Intern)` tag I would then be associated with all of `(Intern)`'s parents `(Harvard)` and `(Berkman)` + + +*Acts as Freetaggable has not been tested on Windows* + +Installation +----- +Acts as Freetaggable is quite easy to use. All you need to do is install the plugin with + + script/plugin install git://github.com/rkneufeld/acts_as_freetaggable + +During the installation process AAF will copy a DB migration (uniquely named) into #{RAILS\_ROOT}/db/migrations and symlink its own plugins into #{RAILS\_ROOT}/vendor/plugins (unless they already exist) + +You will need to + + rake db:migrate + +the new migration into your DB. *You may need to rename the copied migration to be newer than any you already have.* + +Usage +-------- + +After this initial setup you need only call + + acts_as_freetaggable + +on any model you want to be taggable. At the moment the plugin only supplies model-level functionality, so you'll have to throw together your own views/controllers, or you can use the ones supplied with acts\_as\_category. For example: + + class Contact + acts_as_freetaggable + + # ... Other fancy stuff + end + +Now we can call a multitude of different methods on both Contacts and Tags. + +On a contact we can do: + + contact.tags + +And on Tag and Tags we can do a whole lot more. Here are a few examples. More are listed [here](http://github.com/funkensturm/acts_as_category/tree/master). + + Tag.roots + tag.children + tag.contacts # if Contact acts_as_freetaggable + tag.siblings + tag.parent + +Any combination will do, your imagination is the limit... + +Testing +------- + +`rake freetaggable:specs` from RAILS_ROOT should work. + +*Currently 8 tests are failing under postgreSQL in tag\_ordering\_spec.rb and have previously passed. This is something I am working on correcting* + +Copyright (c) 2009 Ryan Neufeld, released under the MIT license diff --git a/vendor/plugins/acts_as_freetaggable/spec/fixtures/tags.yml b/vendor/plugins/acts_as_freetaggable/spec/fixtures/tags.yml new file mode 100644 index 0000000..3e60e2d --- /dev/null +++ b/vendor/plugins/acts_as_freetaggable/spec/fixtures/tags.yml @@ -0,0 +1,47 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html + +# Tree layout +#=============== +# +# - root +# \---tag_tag_one +# \--tag_two +# \--tag_two_one +# +# - root2 +# \---tag_three +# + +root: + title: Root + position: 1 + description: A root tag + +tag_one: + title: tag 1.1 + position: 1 + description: second level, first tag. + parent: root + +tag_two: + title: tag 1.2 + position: 2 + description: second level, second tag. + parent: root + +tag_two_one: + title: tag 1.2.1 + position: 1 + description: third level, third tag. + parent: tag_two + +root2: + title: Another Root + position: 2 + description: Another root tag + +tag_three: + title: tag 2.1 + position: 1 + description: second level, first tag. + parent: root2 diff --git a/vendor/plugins/has_many_polymorphs b/vendor/plugins/has_many_polymorphs index c3e7c2d..d4375dc 120000 --- a/vendor/plugins/has_many_polymorphs +++ b/vendor/plugins/has_many_polymorphs @@ -1 +1 @@ -acts_as_freetaggable/vendor/plugins/has_many_polymorphs \ No newline at end of file +/home/djcp/rails/cohort/vendor/plugins/acts_as_freetaggable/vendor/plugins/has_many_polymorphs \ No newline at end of file