Best Rails Tagging Plugin/Gem
Here's a good list of tagging plugins ordered by ranking.
Recommendations for good 'paging' and 'tagging' plugins/gems in Rails 3?
Checkout Ruby Toolbox
It shows you what gems are available and which are popular choices. In your case: will_paginate and acts-as-taggable-on
Good approach to a tagging system in Rails 3?
I would use a join table between the tags and the taggableItems. Then with a before_create you could check if the tag's are already in the system and create them if they aren't in the system. Next you could use searchlogic (i think there is a rails 3 branch on github) for easy tag/taggableItems searching. And it would be nice to give the user some feedback of the available tags with some autocompletion or a short list of most used tags but that is up to you/the design.
Getting rails tagging plugins to work makes me Hulk-angry
I have used mbleigh's acts-as-taggable-on, and the basic procedure goes:
- Add
config.gem "acts-as-taggable-on"
to environment.rb - Run
rake gems:install
- Run
script/generate acts_as_taggable_on_migration
- Do any customizations on the migration you might want (you probably won't need to).
- Run the migration,
rake db:migrate
- Add
acts_as_taggable_on :your_desired_tag_names
to your tagged model (pluralized).- I.e. Photo model has
:colors
tag. - If you are getting a
NoMethodError
, you may have skipped this step.
- I.e. Photo model has
- To set the models tags, use
photo.color_list = 'abc, 123, def, 456'
- Save the model:
photo.save
- List the tags:
photo.colors
- You might have to reload the model from the database for the
photo.colors
method to be available.
- You might have to reload the model from the database for the
Check out the acts-as-taggable-on readme for more instructions/examples.
How to add tagging with autocomplete to an existing model in Rails?
acts_as_taggable_on and rails3-jquery-autocomplete work nicely together to make a SO like tagging system see example below. I don't think a suitable all in one option exists yet for rails.
Follow these steps to get this all installed:
1 . Backup your rails app!
2 . Install jquery-rails
Note: You can install jQuery UI with jquery-rails
but I chose not to.
3 . Download and install jQuery UI
Choose a theme that will compliment your web design (be sure to test the autocomplete demo with the theme you choose, the default theme did not work for me). Download the custom zip and place the [zipfile]/js/jquery-ui-#.#.#.custom.min.js
file into your app's /public/javascripts/
folder. place the [zipfile]/css/custom-theme/
folder and all files into your app's public/stylesheets/custom-theme/
folder.
4 . Add the following to your Gemfile and then run "bundle install"
gem 'acts-as-taggable-on'
gem 'rails3-jquery-autocomplete'
5 . From the console run the following commands:
rails generate acts_as_taggable_on:migration
rake db:migrate
rails generate autocomplete:install
Make these changes in your app
Include the necessary javascript and css files in your application layout:
<%= stylesheet_link_tag "application", "custom-theme/jquery-ui-1.8.9.custom" %>
<%= javascript_include_tag :defaults, "jquery-ui-#.#.#.custom.min", "autocomplete-rails" %>
Controller Example
EDIT: Made changes based on Seth Pellegrino's comments.
class ArticlesController < Admin::BaseController
#autocomplete :tag, :name <- Old
autocomplete :tag, :name, :class_name => 'ActsAsTaggableOn::Tag' # <- New
end
Model Example
class Article < ActiveRecord::Base
acts_as_taggable_on :tags
end
Route.rb
resources :articles do
get :autocomplete_tag_name, :on => :collection
end
View Example
<%= form_for(@article) do |f| %>
<%= f.autocomplete_field :tag_list, autocomplete_tag_name_articles_path, :"data-delimiter" => ', ' %>
# note tag_list above is a virtual column created by acts_as_taggable_on
<% end %>
Note: This example assumes that you are only tagging one model in your entire app and you are only using the default tag type :tags. Basically the code above will search all tags and not limit them to "Article" tags.
What rails plugins are good, stable and *really* enhance your code?
You can use bort as reference
Plugins Installed
Bort comes with a few commonly used
plugins installed and already setup.RESTful Authentication
RESTful Authentication is already
setup. The routes are setup, along
with the mailers and observers.
Forgotten password comes setup, so you
don’t have to mess around setting it
up with every project.The AASM plugin comes pre-installed.
RESTful Authentication is also setup
to use user activation.User Roles
Bort now comes with Role Requirement
by Tim Harper. A default admin role is
predefined along with a default admin
user. See the migrations for the admin
login details.Open ID Authentication
Bort, as of 0.3, has Open ID
integrated with RESTful
Authentication. Rejoice!Will Paginate
We use will_paginate in pretty much
every project we use, so Bort comes
with it pre-installed.Rspec & Rspec-rails
You should be testing your code, so
Bort comes with Rspec and Rspec-rails
already installed so you’re ready to
roll.Exception Notifier
You don’t want your applications to
crash and burn so Exception Notifier
is already installed to let you know
when everything goes to shit.Asset Packager
Packages up your css/javascript so
you’re not sending 143 files down to
the user at the same time. Reduces
load times and saves you bandwidth.
p/s: agree with @eric, specifics
How can I use a gem/plugin to make my Rails views SEO-friendly (beyond slugs)?
There's a gem called meta-tags, which you may want to check out.
It simplifies the creation of the description and keyword metadata elements. The description and keyword metadata are two of the primary non-visible elements that will help with SEO.
github: kpumuk/meta-tags
Related Topics
Ruby To_JSON Issue with Error "Illegal/Malformed Utf-8"
Ruby Open-Uri Redirect Forbidden
Ruby Find String in File and Print Result
Kernel#Gets Attempts to Read File Instead of Standard Input
Calculating Difference in Time Between Two Time Objects
Rails Strip Non Numeric Values Before Save
Executing User-Supplied Ruby Code on a Web Server
Execute Ruby Code in Sublime Text 2
Does Ruby Have the Java Equivalent of Synchronize Keyword
Why Doesn't Rails' "Errors.Full_Messages" Replace Attribute and Message Variables
Subtract N Hours from a Datetime in Ruby
Ruby: Compare 2 Arrays for Matches, and Count the Number of Match Instances
Ruby 2.0 How to Uninclude a Module Out from a Module After Including It
How Would I Save Multiple Records at Once in Rails
How to Make Carrierwave Delete the File When Destroying a Record