acts-as-taggable-on

Listing all tags for an acts_as_taggable

拈花ヽ惹草 提交于 2019-12-24 07:36:10
问题 I have an app that has factoids that have tags using the acts_as_taggable gem. I currently have it setup so that when on the index page for the factoids, clicking on any of the tags filters the factoids by that tag. What I am attempting to do now is create an index page that lists all of the tags in the app. This seemed rather straight forward... create a tag.rb create a tags_controller.rb add a view in tags/index.html.erb The problem is that this causes my previously implemented search to

Why is .each repeating the array after completion in my rails view? [duplicate]

一笑奈何 提交于 2019-12-24 02:23:43
问题 This question already has answers here : What is the difference between <%, <%=, <%# and -%> in ERB in Rails? (7 answers) Closed 4 months ago . In my rails view page, I have the following loop that should loop through my tag_list array and print each tag: <%= @user.profile.tag_list.each do |tag| %> <%= tag %> <% end %> For some reason, it repeats the array after it prints each individual tag. For example, this array has two elements: ["ruby", "python"] The output of the each method is

Rails add two scope with active record result

这一生的挚爱 提交于 2019-12-23 12:58:30
问题 I am using acts-as-taggable-on gem i use single field to search by tag_name and user_name User.rb class User < ActiveRecord::Base acts_as_taggable attr_accessor: :user_name, :age, :country, tag_list scope :tagged_with, lambda { |tag| { :joins => "INNER JOIN taggings ON taggings.taggable_id = user.id\ INNER JOIN tags ON tags.id = taggings.tag_id AND taggings.taggable_type = 'User'", :conditions => ["tags.name = ?", tag], :order => 'id ASC' } } def self.search(search) if search where('name LIKE

Rails:acts-as-taggable-on: Using tagged_with on a relation

感情迁移 提交于 2019-12-23 05:26:54
问题 Lets say I have a Model A which has a 1 to 1 association with Model B. Model B is set to 'acts_as_taggable'. I would like to return an active record relation that selects all A instances who's B attribute is tagged_with a certain string. It would look something like: A.where('b.tagged_with = ?', 'some_tag') I found this SO question, but i'm interested in getting an active record relation back so only the 2nd solution is applicable and I can't get it to work. How can I get back active record

how to find entries with no tags using acts-as-taggable-on?

拜拜、爱过 提交于 2019-12-23 02:22:16
问题 What's the Right Way(tm) to find the entries that have no tags? I tried using Entry.tagged_with(nil) but it just returns an empty hash. I need it so I can list the entries I still need to tag. Thanks. 回答1: Without knowing the internals of acts-as-taggable-on I can't think of a neat way that doesn't involve looping queries or raw SQL. This is readable: need_to_tag = [] Entry.all.each do |e| need_to_tag << e if e.tag_list.blank? end need_to_tag then holds any untagged Entries. 回答2: The

Using acts-as-taggable-on how do I find the top, say 10, tags in my app?

笑着哭i 提交于 2019-12-22 10:27:06
问题 Basically, I want to sort all the tags by the number of taggings they have. I am trying to create navigation using the tags. So I want to display just the top 5, 10, 15, X tags sorted by the number of items they have tagged. So I can't do any operation on a model, and there isn't a controller I can do it in either - I may just have to do it in the navigation view partial. But I don't even know how to query acts-as-taggable-on to allow me to find the top X tags in the system. How do I do that

How to cache tags with acts_as_taggable_on?

懵懂的女人 提交于 2019-12-19 07:07:14
问题 I have model with tag context: class Product < ActiveRecord::Base acts_as_taggable_on :categories end I'm trying to initialize tags caching: class AddCachedCategoryListToProducts < ActiveRecord::Migration def self.up add_column :products, :cached_category_list, :string Product.reset_column_information products = Product.all products.each { |p| p.save_cached_tag_list } end end But cached_category_list does not initializing. What I'm doing wrong? Does anybody can use caching with this gem (my

Rails acts as taggle on filter by multiple tags

笑着哭i 提交于 2019-12-18 18:20:56
问题 I have a model, Tasks, that can be tagged with the acts as taggable on gem. The route: get 'mainpage/:tag', to: 'mainpage#index', as: :tag Right now, when you click on a tag, it brings you to all tasks with that tag. What I'd like to do is make it so that once you're on a tag page, clicking an additional tag further filters the results with the clicked tag name. Ex. On page for tag bills (mainpage/bills) displays: Cable (tagged with: tv, credit card. bills) Chairs (tagged with: credit card,

acts_as_taggable_on Tags added twice

非 Y 不嫁゛ 提交于 2019-12-13 16:24:08
问题 I have a RoR app that allows users to tag items in their collections. I use the tag-it.js Jquery plugin and use Ajax calls to add and remove the tags in the ItemsController. My problem is that each tag is added twice so that when I do @item.tags.each, all the tags are shown twice. ItemsController: def add_tag @collection = current_user.collections.find(params[:collection_id]) @item = @collection.items.find(params[:id]) @item.tag_list.add(params[:tag]) current_user.tag(@item, :with => @item

Rails 4 - Acts as Taggable on gem - set up errors

喜欢而已 提交于 2019-12-13 07:26:58
问题 I am trying to make an app with Rails 4. I am trying to use gem 'acts-as-taggable-on', '~> 3.4' I found this tutorial showing how to set it up: https://www.reddit.com/r/rails/comments/2chtgw/tagging_in_rails_4/ I have an articles controller, which has included tag_list in the strong params: def article_params params[:article].permit(:user_id, :body, :title, :image, :tag_list, comment_attributes: [:opinion]) end I have an articles form, with: <%= simple_form_for(@article) do |f| %> <%= f.error