acts-as-taggable-on

How to use multiple models for tag_cloud?

亡梦爱人 提交于 2019-12-04 04:00:50
问题 _tags.html.erb #Version 1 (Just lists out habits tags) <% tag_cloud Habit.tag_counts, %w{s m l} do |tag, css_class| %> <%= link_to tag.name, tag_path(tag.name), class: css_class %> <% end %> #Version 2 <% tag_cloud(@tags, %w(css1 css2 css3 css4)) do |tag, css_class| %> <%= link_to tag.name, { :action => :tag, :id => tag.name }, :class => css_class %> <% end %> How can we get it where it list's out the current_user 's habits AND goals, valuations, quantifieds? f.text_field :tag_list is in the

Error sideloading JSON for act-as-taggable tags using active-model-serializers

无人久伴 提交于 2019-12-03 13:37:45
In a Ruby 2/Rails 4 app, I am trying to use acts-as-taggable-on in conjunction with active_model_serializers in order to create a JSON API that would output my tags along with other model parameters. First some background/motivation for this issue: The JSON is being fed into ember/ember-data, which as of the time of this writing has removed support for embedded records in JSON. There is a supposed fix in the documentation about this, but I find it clumsy and also haven't actually gotten it to work. Since I'm an Ember newbie and am a little more comfortable with Rails, I figure I'll try to

Using jquery tokeninput and acts_as_taggable_on

假装没事ソ 提交于 2019-12-03 08:44:17
I've implemented the framework outlined in this post: How to use jquery-Tokeninput and Acts-as-taggable-on with some difficulty. This is working insofar as prepopulating with the appropriate theme and ajax search, but when I enter a new tag, it is immediately deleted when the text area loses focus. I'm not sure what I'm doing wrong. Here's some of my relevant code: User Model (does the tagging): class User < ActiveRecord::Base [...] # tagging acts_as_tagger Item Model (accepts a tag): class Item < ActiveRecord::Base attr_accessible :title, :tag_list #tagging functionality acts_as_taggable_on

acts_as_taggable_on: how to optimize the query?

我只是一个虾纸丫 提交于 2019-12-03 06:32:01
I use acts_as_taggable_on in my current Rails project. On one overview page i am displaying an index of objects with their associated tags. I use the following code: class Project < ActiveRecord::Base acts_as_taggable_on :categories end class ProjectsController < ApplicationController def index @projects = Project.all end end # in the view <% @projects.each do |p| %> <%= p.name %> <% p.category_list.each do |t| %> <%= t %> <% end %> <% end %> This all works as expected. However, if i am displaying 20 projects, acts_as_taggable_on is firing 20 queries to fetch the associated tags. How can I

How to get a list of all tags while using the gem 'acts-as-taggable-on' in Rails (not the counts)

泄露秘密 提交于 2019-12-03 04:23:37
问题 I have set the acts-as-taggable-on gem in my model like this : acts_as_taggable_on :deshanatags It use the context deshanatags . Now I need to get a list of all the tags (not only the ones assigned for one item. I need everything) in this context in the following format : [ {"id":"856","name":"House"}, {"id":"1035","name":"Desperate Housewives"} ] How can I do this? I tried to follow many tutorials but hit dead ends because most of them are written for Rails 3. Rails for have some changes to

How to get a list of all tags while using the gem 'acts-as-taggable-on' in Rails (not the counts)

烈酒焚心 提交于 2019-12-02 17:38:58
I have set the acts-as-taggable-on gem in my model like this : acts_as_taggable_on :deshanatags It use the context deshanatags . Now I need to get a list of all the tags (not only the ones assigned for one item. I need everything) in this context in the following format : [ {"id":"856","name":"House"}, {"id":"1035","name":"Desperate Housewives"} ] How can I do this? I tried to follow many tutorials but hit dead ends because most of them are written for Rails 3. Rails for have some changes to the model like removal of attr_accessor which make it difficult for me to understand those tutorials.

Search form with acts_as_taggable_on (Rails 3)

本秂侑毒 提交于 2019-12-02 10:27:15
问题 I have a searchbox to search for products. Each product has a title and is tagged with multiple tags. I want to be able to search for products by title or tag. In other words if I have a product called "Green Tea" and another product tagged "green, red, blue" and I type "green" into the searchbox, I'd like both products to appear in the search results. I am using Rails 3, acts_as_taggable_on, Ruby 1.9.2. 回答1: In your controller, the action that displays the search results could look something

How to use multiple models for tag_cloud?

99封情书 提交于 2019-12-01 19:07:27
_tags.html.erb #Version 1 (Just lists out habits tags) <% tag_cloud Habit.tag_counts, %w{s m l} do |tag, css_class| %> <%= link_to tag.name, tag_path(tag.name), class: css_class %> <% end %> #Version 2 <% tag_cloud(@tags, %w(css1 css2 css3 css4)) do |tag, css_class| %> <%= link_to tag.name, { :action => :tag, :id => tag.name }, :class => css_class %> <% end %> How can we get it where it list's out the current_user 's habits AND goals, valuations, quantifieds? f.text_field :tag_list is in the _form of each of these four models, which are also separate tables in the database. I also added the

How to cache tags with acts_as_taggable_on?

旧时模样 提交于 2019-12-01 05:22:44
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 version is 2.0.6)? If you are using this in combination with owned tags, that might be the problem.

Rails acts-as-taggable-on with select2 (and simple_form)

落花浮王杯 提交于 2019-11-30 21:29:35
I would like to have a select2 dropdown of tags, where i could select multiple existing tags and add new ones. I have tried many different ways and i either don't get select2 box working or only one value is passed (last one). This is closest i got (passes last value): <%= f.input :tag_list, collection: @model.tags.map { |t| t.name }, input_html: { :style=> 'width: 300px', class: "taggable", data: { placeholder: "Tags" }} %> As I mentioned before, normal select2 library now uses only select input types, but it does work with input types when using select2-full library. So, this was a way out