Topic: HOWTO: Get started with acts_as_taggable_on_steroids

This is just a basic example of how to get started with this plugin that lets you easily implement tagging into your Rails app:

ruby script/plugin install http://svn.viney.net.nz/rails/plugins/a … n_steroids

I will also be paginating the tags, so install the will_paginate plugin:

svn://errtheblog.com/svn/plugins/will_paginate

To start with you need to add the line 'acts_as_taggable' to the Model that you want to add tags to eg:

Class Movie
acts_as_taggable
end

Then, add the tags text_field within the form fields of the relevant form (i am being RESTful here) eg...

movies/new.rhtml:

<% form_for(:movie, :url => movies_path) do |f| %>
Title: <%= f.text_field :title %>
Description: <%= f.text_area :description %>
Tags (seperate with comma ','): <%= f.text_field :tag_list %>
<%= submit_tag "Create" %>
<% end %>

Create your Tags Controller:

class TagsController
def index
@tags = Tag.find(:all)
end

def show
@tag = Tag.find(params[:id])
@movies = Movie.paginate_by_id(Movie.find_tagged_with(@tag), :page => params[:page], :per_page => 3)
end
end


tags/index.rhtml:

TAG List...
<% @tags.each do |t| %>
<%= link_to t.name.capitalize, tag_path(t) %>
<% end %>

tags/show.rhtml:

TAG: <%= @tag.name.capitalize %>
<% @movies.each do |m| %>
<%= link_to m.title, movie_path(m.id) %>
<%= m.description %>
<% end %>
<%= will_paginate @movies %>

This will basically let you add tags to new 'movies', view a list of all tags, and then also see a list of all 'movies' tagged with a particular tag - and this list is paginated. Of course you can also implement Tag clouds, checkout the plugins readme file for more info

Re: HOWTO: Get started with acts_as_taggable_on_steroids

when I try to install acts_as_taggable_on_steroids

allagash:helpdesk richard$ script/generate acts_as_taggable_migration
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:266:in `load_missing_constant': uninitialized constant Cacher (NameError)
    from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:453:in `const_missing'
    from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:465:in `const_missing'
    from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/inflector.rb:257:in `constantize'
    from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/core_ext/string/inflections.rb:148:in `constantize'
    from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/observer.rb:38:in `instantiate_observers'
    from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/observer.rb:36:in `each'
    from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/observer.rb:36:in `instantiate_observers'
    from /opt/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/initializer.rb:216:in `load_observers'
     ... 6 levels...
    from /opt/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/generate.rb:1
    from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
    from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
    from script/generate:3
allagash:helpdesk richard$

also when i try just acts_as_taggable I get the following:
allagash:helpdesk richard$ script/plugin install acts_as_taggable
/opt/local/lib/ruby/1.8/timeout.rb:54:in `rbuf_fill': execution expired (Timeout::Error)
    from /opt/local/lib/ruby/1.8/timeout.rb:56:in `timeout'
    from /opt/local/lib/ruby/1.8/timeout.rb:76:in `timeout'
    from /opt/local/lib/ruby/1.8/net/protocol.rb:132:in `rbuf_fill'
    from /opt/local/lib/ruby/1.8/net/protocol.rb:116:in `readuntil'
    from /opt/local/lib/ruby/1.8/net/protocol.rb:126:in `readline'
    from /opt/local/lib/ruby/1.8/net/http.rb:2029:in `read_status_line'
    from /opt/local/lib/ruby/1.8/net/http.rb:2018:in `read_new'
    from /opt/local/lib/ruby/1.8/net/http.rb:1059:in `request'
     ... 25 levels...
    from /opt/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/plugin.rb:923
    from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
    from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
    from script/plugin:3

what is missing?

Re: HOWTO: Get started with acts_as_taggable_on_steroids

No sure if this is valid question anymore but I found this very helpful:
http://www.bin-co.com/blog/2007/12/inst … ls-plugin/

Elle