Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6031833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:14:37+00:00 2026-05-23T05:14:37+00:00

I am using acts-as-taggable-on and without any luck been trying to figure this out

  • 0

I am using acts-as-taggable-on and without any luck been trying to figure this out for awhile now. For some reason i cannot get my tags to show up or save inside of the database.I really need some help, i looked online and the documentation is intermediate or not newbie friendly. Here is my code:

Devise User Model:

class User < ActiveRecord::Base

  has_many :products, :dependent => :destroy
  acts_as_tagger
end

Products Model:

class Product < ActiveRecord::Base
    attr_accessible :name, :date, :price, :tag_list

    acts_as_taggable_on :tags

    belongs_to :user
end

Form:

  <div class="field"> 
    <%= f.label :tag_list %>
    <%= f.text_field :tag_list %>
  </div>

Show View:

<p>
    <b>Tags:</b> 
    <%= @product.tag_list %>     
</p>

EDIT WITH UPDATED AND WORKING CODE:

I am using Devise and letting only the current_user (user_id in products table) do actions such as create,destroy,update tags,etc.

User Model:

class User < ActiveRecord::Base 
  has_many :products,        :dependent => :destroy
  acts_as_tagger
end

Product Model:

class Product < ActiveRecord::Base
    attr_accessible :name, :date, :price, :tag_list, :longitude, :latitude

    acts_as_taggable_on :tags
end

Products Controller:

class ProductsController < ApplicationController
  before_filter :authenticate_user!

  def index
    @products = Product.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @products }
    end
  end

  def show
    @product = Product.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @product }
    end
  end

  def new
   @product = Product.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @product }
    end
  end

  def edit
    @product = current_user.products.find(params[:id])

    @product.user = current_user
  end

  def create
    @product = current_user.products.build(params[:product])
    @product.user = current_user

    respond_to do |format|
      if @product.save
        format.html { redirect_to(@product, :notice => 'Product was successfully created.') }
        format.xml  { render :xml => @product, :status => :created, :location => @product }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @product.errors, :status => :unprocessable_entity }
      end
    end
  end

  def update
    @product = current_user.products.find(params[:id])
    @product.user = current_user

    respond_to do |format|
      if @product.update_attributes(params[:product])
        format.html { redirect_to(@product, :notice => 'Product was successfully updated.') }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @product.errors, :status => :unprocessable_entity }
      end
    end
  end

  def destroy
    @product = current_user.products.find(params[:id])
    @product.destroy

    respond_to do |format|
      format.html { redirect_to(products_url) }
      format.xml  { head :ok }
    end
  end
end

products/index.html.erb:

<td><%= product.tag_list %></td>

products/show.html.erb:

<p>
    <b>Tags:</b> 
    <%= @product.tag_list %>     
</p>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T05:14:38+00:00Added an answer on May 23, 2026 at 5:14 am

    Try using this code in your view:

    <p>
        <b>Tags:</b> 
        <%= @product.tags %>     
    </p>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to install acts_as_ferret in windows7.But am getting an error Using acts-as-taggable-on (2.1.1)
I am using acts-as-taggable-on for a Rails application and every time I create a
I'm using acts_as_taggable_on and I'm trying to query for all users tagged with any
Until now, I've been using acts_as_taggable_on plugin for tagging announcements. That plugin creates the
Hi I am working on a Rails 3 project and I am using acts-as-taggable-on
Am using below specified gem acts-as-taggable-on(2.2.2) will_paginate(3.0.2) rails(3.0.3) ruby 1.8.7 i tried to use
I am using the old auto_complete plugin in conjunction with the acts as taggable
I am using acts-as-taggable on. Two models: User and Posts. Posts belongs_to :user User
I'm creating a Related content area on a website and using the acts-as-taggable-on gem
I'm using acts-as-taggable-on in my application and I want to be able to use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.