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 7774251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:19:52+00:00 2026-06-01T17:19:52+00:00

I’m creating a simple project tagging application using the Act_As_Taggable_On gem. Adding projects, and

  • 0

I’m creating a simple project tagging application using the Act_As_Taggable_On gem.

Adding projects, and adding tags (in my case ‘types’ / ‘type_list’) to each project works great. Where I’m stuck is how to remove individual tags using Act_As_Taggable_On. What I would like is to be able to click the ‘x’ text link next to each tag (see link) to remove the tag from that projects type_list.

I’ve searched the documentation and found a method along the lines of:

project.type_list.remove("your tag")

But what I need help with is how to call the remove method on the specific tag, especially since the whole thing is being iterated with .each do

My controller and model code is pretty minimal and standard – based on Act_As_Taggable_On docs. Here is my view code for generating the layout above:

<h1><%= @title %></h1>
<div class="column-left">
  <% @projects.each do |project| %>
    <div class="p_wrapper">

      <table>
        <tr>
          <td><div class="project p_name"><%= project.name %></div></td>
          <td><div class="p_link"><%= link_to 'Edit', edit_project_path(project) %></div></td>
          <td><div class="p_link"><%= link_to 'Nuke', project, :confirm => 'Are you sure?', :method => :delete %></div></td>
        </tr>
      </table>

      <table>
        <tr>
          <td>
              <% project.type_list.each do |tag|%>
                <div class="p_tag">
                <%= tag %> 
                <%= link_to "x", # %> <!-- THIS IS THE PART I'M STUCK ON -->
              </div> 
              <% end %>
            </td>
        </tr>
      </table>

      <table>
        <tr>
            <td>
              <%= form_for(project) do |f| %>
              <%= f.text_field :inject_tags %>  
              <%= f.submit "Add Tag" %>
              <% end %>
            </td>
        </tr>
      </table>

    </div>

  <% end %>

  <br />

  <%= link_to 'Add new project', new_project_path %>
</div>

Can anyone point me in the right direction? Am I implementing this correctly to be able to actually remove tags as described?

Thanks guys!

  • 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-06-01T17:19:53+00:00Added an answer on June 1, 2026 at 5:19 pm

    Based on @Vapire’s suggested code – finally worked out a working solution. Just some minor edits to the view, route, and controller. Let me know if you see anything dodgy in here – still trying to get a good grasp of Ruby/Rails so all suggestions/refactoring ideas welcome.

    The updated test site is at project-list.heroku.com.

    Updated projects controller to find current project, remove :tag passed from index view through route:

    def remove_tag
      @project = Project.find(params[:id])
      @project.type_list.remove(params[:tag])
      @project.save
      redirect_to projects_path, :flash => { :success => "Updated - tag nuked."}
    end
    

    Updated route:

    resources :projects
    match 'projects/:id/remove_tag/:tag' => 'projects#remove_tag'
    

    Updated the link_to ‘x’ code to pass :tag params through the updated route above:

    <% project.type_list.each do |tag|%>
      <div class="p_tag">
        <%= tag %> 
        <%= link_to 'x', {:action => "remove_tag", :id => project.id, :tag => tag, 
        :controller => "projects"} %>
      </div> 
    <% end %>
    

    This is obviously new ground for me so would appreciate if you have a different / better way of handling this issue please let me know! Also, thanks for your help @Vapire!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.