github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

geemus / acts_as_taggable_redux

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 106
    • 16
  • Source
  • Commits
  • Network (16)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Allows user owned tags for multiple classes, and makes tags easier to work with. — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

fix sorting typo in helper 
Akshay Shah (author)
Mon Oct 05 13:11:20 -0700 2009
geemus (committer)
Mon Oct 05 13:30:06 -0700 2009
commit  88d85aa0865e2c29ccf24855f9cd02a37d6744fb
tree    15eba9cd414889675877b3808ccc88f01b914bff
parent  577919a39162ec93545cebf3638836afcf8ecc64
acts_as_taggable_redux /
name age
history
message
file MIT-LICENSE Tue May 15 18:56:38 -0700 2007 initial import of plugin as seperate bit git-s... [monki@geemus.com]
file README Thu May 15 12:18:57 -0700 2008 Fixed bug: user_id= method overshadowed real us... [skwp]
file Rakefile Tue May 15 18:56:38 -0700 2007 initial import of plugin as seperate bit git-s... [monki@geemus.com]
file acts_as_taggable_redux.gemspec Sat Jul 11 15:23:22 -0700 2009 fix missing comma in gemspec [geemus]
directory generators/ Fri May 25 15:47:42 -0700 2007 per user tagging, without breaking not per user... [monki@geemus.com]
file init.rb Wed Nov 26 06:40:07 -0800 2008 Basic gem version. [nagybence]
directory lib/ Mon Oct 05 13:30:06 -0700 2009 fix sorting typo in helper [akshayshah]
directory tasks/ Sat Dec 06 12:41:02 -0800 2008 add tasks back for css/db tasks, clean up gemspec [Wesley Beary]
directory test/ Thu May 15 12:18:57 -0700 2008 Fixed bug: user_id= method overshadowed real us... [skwp]
README
ActsAsTaggableRedux
===================

Allows for user owned tags to be added to multiple classes, and makes tags easier to work with.


Prerequisites
=============

Install Edge Rails before you get started so you get RESTful routing.

ActsAsTaggableRedux depends on database tables to store tagging information.  Create the migration for these tables with 
this command:
  
  rake acts_as_taggable:db:create
  
Then run the migration to create the tables with this command:
  
  rake db:migrate
  
Also you will need to add this to your user model:
  acts_as_tagger
  
OPTIONAL: The helper functions assume the pressence of a tags controller, that is what the tag clouds and tags will link 
to.
  
OPTIONAL: To pretty up tag clouds and lists you can generate an example stylesheet with this command:

  rake acts_as_taggable:stylesheet:create

and then include this in your layouts that have tag clouds:

  <%= stylesheet_link_tag 'acts_as_taggable_stylesheet' %>


Example
=======

The following is an example of how you might integrate tags with an Item model.

config/routes.rb
  may.resource :items, :tags
  
  
app/views/items/new.erb
  <h1>New Item</h1>
  
  <% form_for(:item, @item) do |f| -%>
    
    <%= error_message_for :item %>
    
    <b>Tags:</b> <%= f.text_field :tag_list -%>
    
    <%= submit_tag "Save" -%>
    
  <% end -%>
  
if you want users to own taggings change the tags line to this
  <b>Tags:</b> <%= f.text_field :tag_list, :value => @item.tag_list(user) -%>
and add this line beneath it
  <%= f.hidden_field :user_id, :value => user.id -%>
  
app/views/items/show.erb
  Item tagged with: 
  <% item.tags.each do |tag| -%>
    <%= link_to_tag(tag) %>
  <% end -%>
  
app/views/items/edit.erb
  <h1>New Item</h1>
  
  <% form_for(:item, @item, :html => { :method => :post }) do |f| -%>
  
    <%= error_messages_for :item %>
    
    <b>Tags:</b> <%= f.text_field :tag_list -%>
    
    <%= submit_tag "Save" -%>
  
  <% end -%>


app/controllers/items_controller.rb
  class ItemController < ApplicationController
    def new
      @item = Item.new
    end
    
    def create
      @item = Item.new(params[:item])
      
      respond_to do |format|
        if @item.save
          flash[:notice] = 'Item was successfully created.'
          format.html { redirect_to item_url(@item) }
          format.xml  { head :created, :location => item_url(@item) }
        else
          format.html { render :action => "new" }
          format.xml  { render :xml => @item.errors.to_xml }
        end
      end
    end

    def show
      @item = Item.find(params[:id], :include => :tags)
    end
    
    def edit
      @item = Item.find(params[:id])
    end
    
    def update
      @item = Item.find(params[:id])
      
      respond_to do |format|
        if @item.update_attributes(params[:item])
          flash[:notice] = 'Item was successfully updated.'
          format.html { redirect_to item_url(@item) }
          format.xml  { head :updated, :location => item_url(@item) }
        end
          format.html { render :action => "edit"}
          format.xml  { render :xml => @item.errors.to_xml}
      end
    end
  end



Tag clouds
==========

Tag clouds are created by a helper function, and depend on the counter cache to get fast accurate counts.  To ensure 
this keeps working properly, don't add new tags to a taggable in any way other than using the tag.tag(taggable) style.  
This will ensure that the caches don't lose track.  Also, see the prerequisites for installing the stylesheet so that 
the tag cloud actually looks like a tag cloud.  Otherwise, just pop into a view that you want the tag cloud to appear 
and type this:

  <%= tag_cloud %>
  
  
  
Contributing
============

Welcoming all pull requests on github.com at http://github.com/monki/acts_as_taggable_redux/tree/master or 
git://github.com/monki/acts_as_taggable_redux.git



Copyright (c) 2008 monki(Wesley Beary), released under the MIT license
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server