<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Blog, Social networking, SEO, Technology, Softwares &#124; Smarteguru&#187; tagging</title>
	<atom:link href="http://blogs.smarteguru.com/tag/tagging/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.smarteguru.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Fri, 16 Jul 2010 11:51:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>SEO by Ruby on rails Plugin &#8211; Acts As Taggable On Steroids</title>
		<link>http://blogs.smarteguru.com/ruby-on-rails/seo-by-ruby-on-rails-plugin-acts-as-taggable-on-steroids/</link>
		<comments>http://blogs.smarteguru.com/ruby-on-rails/seo-by-ruby-on-rails-plugin-acts-as-taggable-on-steroids/#comments</comments>
		<pubDate>Fri, 26 Sep 2008 06:58:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[Acts As Taggable On Steroids]]></category>
		<category><![CDATA[acts_as_taggable]]></category>
		<category><![CDATA[acts_as_taggable_on_steroids]]></category>
		<category><![CDATA[ror plugin]]></category>
		<category><![CDATA[ruby on rails plugin]]></category>
		<category><![CDATA[seo with rails]]></category>
		<category><![CDATA[tag cloud]]></category>
		<category><![CDATA[tagging]]></category>

		<guid isPermaLink="false">http://blogs.smarteguru.com/?p=296</guid>
		<description><![CDATA[This plugin is based on acts_as_taggable by DHH but includes extras such as tests, smarter tag assignment, and tag cloud calculations.
Installation
ruby script/plugin install http://svn.viney.net.nz/things/rails/plugins/acts_as_taggable_on_steroids

Usage
Prepare database
Generate and apply the migration:
  ruby script/generate acts_as_taggable_migration
  rake db:migrate
Basic tagging
Let’s suppose users have many posts and we want those posts to have tags. The first step is to [...]]]></description>
			<content:encoded><![CDATA[<p>This plugin is based on acts_as_taggable by DHH but includes extras such as tests, smarter tag assignment, and tag cloud calculations.</p>
<p><strong>Installation</strong></p>
<p><code>ruby script/plugin install http://svn.viney.net.nz/things/rails/plugins/acts_as_taggable_on_steroids</code><br />
<span id="more-296"></span><br />
<strong>Usage</strong></p>
<p>Prepare database</p>
<p>Generate and apply the migration:</p>
<p><code>  ruby script/generate acts_as_taggable_migration<br />
  rake db:migrate</code></p>
<p><strong>Basic tagging</strong></p>
<p>Let’s suppose users have many posts and we want those posts to have tags. The first step is to add acts_as_taggable to the Post class:</p>
<p><code>  class Post < ActiveRecord::Base<br />
    acts_as_taggable<br />
    belongs_to :user<br />
  end</code></p>
<p>We can now use the tagging methods provided by acts_as_taggable, #tag_list and #tag_list=. Both these methods work like regular attribute accessors.</p>
<p><code>  p = Post.find(:first)<br />
  p.tag_list # []<br />
  p.tag_list = "Funny, Silly"<br />
  p.save<br />
  p.tag_list # ["Funny", "Silly"]</code></p>
<p>You can also add or remove arrays of tags.</p>
<p><code>  p.tag_list.add("Great", "Awful")<br />
  p.tag_list.remove("Funny")</code></p>
<p><strong>Finding tagged objects</strong></p>
<p>To retrieve objects tagged with a certain tag, use find_tagged_with.</p>
<p><code>Post.find_tagged_with('Funny, Silly')</code></p>
<p>By default, find_tagged_with will find objects that have any of the given tags. To find only objects that are tagged with all the given tags, use match_all.</p>
<p><code>Post.find_tagged_with('Funny, Silly', :match_all => true)</code></p>
<p>See ActiveRecord::Acts::Taggable::InstanceMethods for more methods and options.<br />
Tag cloud calculations</p>
<p>To construct tag clouds, the frequency of each tag needs to be calculated. Because we specified acts_as_taggable on the Post class, we can get a calculation of all the tag counts by using Post.tag_counts. But what if we wanted a tag count for an single user’s posts? To achieve this we call tag_counts on the association:</p>
<p><code>User.find(:first).posts.tag_counts</code></p>
<p>A helper is included to assist with generating tag clouds. Include it in your helper file:</p>
<p>  <code>module ApplicationHelper<br />
    include TagsHelper<br />
  end</code><br />
<script type="text/javascript"><!--
google_ad_client = "pub-7255962970607901";
google_ad_slot = "6436819828";
google_ad_width = 300;
google_ad_height = 250;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<br />
Here is an example that generates a tag cloud.</p>
<p>Controller:</p>
<p>  <code>class PostController < ApplicationController<br />
    def tag_cloud<br />
      @tags = Post.tag_counts<br />
    end<br />
  end</code></p>
<p>View:</p>
<p><code>&lt;% tag_cloud @tags, %w(css1 css2 css3 css4) do |tag, css_class| %&gt;<br />
&lt;%= link_to tag.name, { :action =&gt; :tag, :id =&gt; tag.name }, :class =&gt; css_class %&gt;<br />
&lt;% end %&gt;</code></p>
<p>CSS:</p>
<p><code>  .css1 { font-size: 1.0em; }<br />
  .css2 { font-size: 1.2em; }<br />
  .css3 { font-size: 1.4em; }<br />
  .css4 { font-size: 1.6em; }</code></p>
<p>Caching</p>
<p>It is useful to cache the list of tags to reduce the number of queries executed. To do this, add a column named cached_tag_list to the model which is being tagged. The column should be long enough to hold the full tag list and must have a default value of null, not an empty string.</p>
<p><code>  class CachePostTagList < ActiveRecord::Migration<br />
    def self.up<br />
      add_column :posts, :cached_tag_list, :string<br />
    end<br />
  end</code></p>
<p><code>  class Post < ActiveRecord::Base<br />
    acts_as_taggable<br />
    # The caching column defaults to cached_tag_list, but can be changed:<br />
    #<br />
    # set_cached_tag_list_column_name "my_caching_column_name"<br />
  end</code></p>
<p>The details of the caching are handled for you. Just continue to use the tag_list accessor as you normally would. Note that the cached tag list will not be updated if you directly create Tagging objects or manually append to the tags or taggings associations. To update the cached tag list you should call save_cached_tag_list manually.<br />
Delimiter</p>
<p>If you want to change the delimiter used to parse and present tags, set TagList.delimiter. For example, to use spaces instead of commas, add the following to config/environment.rb:</p>
<p><code>TagList.delimiter = " "</code><br />
<h3>Related Posts</h3>
<ul class="related_post">
<li><a href="http://blogs.smarteguru.com/ruby-on-rails/integrate-google-analytics-plugin-in-your-application/" title="Integrate Google Analytics Plugin in your application">Integrate Google Analytics Plugin in your application (0)</a></li>
<li><a href="http://blogs.smarteguru.com/general/exception-notifier-ror-plugin-for-notification-error/" title="Exception Notifier : ror plugin for notification error">Exception Notifier : ror plugin for notification error (1)</a></li>
<li><a href="http://blogs.smarteguru.com/ruby-on-rails/server_config-ruby-on-rails-plugin-for-sensitive-configuration/" title="server_config: Ruby on rails plugin for sensitive configuration">server_config: Ruby on rails plugin for sensitive configuration (0)</a></li>
<li><a href="http://blogs.smarteguru.com/ruby-on-rails/activescaffold-plugin-crud-functionality-ruby-on-rails-application/" title="ActiveScaffold plugin: CRUD functionality for ruby on rails application">ActiveScaffold plugin: CRUD functionality for ruby on rails application (1)</a></li>
<li><a href="http://blogs.smarteguru.com/general/plugins-acts-as-authorizable-role-based-authorization/" title="Acts As Authorizable: Ruby on rails plugin for role based authorizations">Acts As Authorizable: Ruby on rails plugin for role based authorizations (0)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blogs.smarteguru.com/ruby-on-rails/seo-by-ruby-on-rails-plugin-acts-as-taggable-on-steroids/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
