acts-as-taggable-on

Changing the default delimiter with acts-as-taggable-on

大憨熊 提交于 2019-12-10 13:56:29
问题 The default delimiter in the acts-as-taggable-on gem is a comma. I'd like to change this to a space throughout my Rails 3 application. For example, tag_list should be assigned like this: object.tag_list = "tagone tagtwo tagthree" rather than like this: object.tag_list = "tagone, tagtwo, tagthree" What is the best way to go about changing the delimiter? 回答1: You need define the delimiter class variable in ActsAsTaggableOn::TagList class In an initializer add that : ActsAsTaggableOn::TagList

ActiveRecord::Relation issue on acts-as-taggable-on

孤者浪人 提交于 2019-12-10 12:17:14
问题 I am a rails newbie. I am trying to implement acts-as-taggable-on on my sample app. I am able to enter multiple tags using tag_list but facing issues searching them. This is what I got. I used scaffold User to generate the controller & model. class CreateUsers < ActiveRecord::Migration def change create_table :users do |t| t.string :name t.text :tags t.timestamps end end end My User Model is class User < ActiveRecord::Base serialize :tags acts_as_taggable_on :tags scope :by_join_date, order(

Rails3 acts_as_taggable with a form

一个人想着一个人 提交于 2019-12-10 11:43:53
问题 I've just started working with the acts_as_taggable gem. Really liking it so far, but I am a bit unclear about how to use this gem with a form. class Photo < ActiveRecord::Base acts_as_taggable_on :tags end In my form for Photos I am trying to implement a series of checkboxes for the user to assign tags to their photo: <%= f.label :tag_list %> <%= f.check_box :tag_list, "landscape" %> <%= f.check_box :tag_list, "people" %> When viewing the form I get this error: NoMethodError in Photos#edit .

Get all tags by context for acts-as-taggable-on

心不动则不痛 提交于 2019-12-10 11:29:21
问题 We use https://github.com/mbleigh/acts-as-taggable-on for our Rails app and we've encountered a problem. We tell users the possible tags for a given model and context based on the recommended (Acts-as-taggable-on find all tags by context) Model.tag_context_counts , but this is generating horribly inefficient queries. As our site is growing this is becoming a problem. For some reason it generates this kind of thing: SELECT recipes.id FROM "recipes" ORDER BY sort_order SELECT tags.*, taggings

acts_as_taggable_on: how to optimize the query?

£可爱£侵袭症+ 提交于 2019-12-09 05:37:15
问题 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

Rails3 acts_as_taggable with a form

人盡茶涼 提交于 2019-12-06 16:36:30
I've just started working with the acts_as_taggable gem. Really liking it so far, but I am a bit unclear about how to use this gem with a form. class Photo < ActiveRecord::Base acts_as_taggable_on :tags end In my form for Photos I am trying to implement a series of checkboxes for the user to assign tags to their photo: <%= f.label :tag_list %> <%= f.check_box :tag_list, "landscape" %> <%= f.check_box :tag_list, "people" %> When viewing the form I get this error: NoMethodError in Photos#edit ...line #19 raised: undefined method `merge' for "landscape":String Extracted source (around line #19):

Showing only the most popular tags in the acts_as_taggable_on tag cloud

…衆ロ難τιáo~ 提交于 2019-12-06 03:21:02
问题 Acts-as-taggable works great and everything but I was wondering if there was a way to restrict the tag cloud to only the most popular tags? Right not it looks like its ordering my cloud by the order in which the tags were created. But it makes more sense to have the tag cloud show only the most popular tags. My controller has: def styles_tag_cloud @tags = Tattoo.tag_counts_on(:styles).limit(40) end and my view has: <% tag_cloud(styles_tag_cloud, %w(css1 css2 css3 css4)) do |tag, css_class| %>

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

被刻印的时光 ゝ 提交于 2019-12-04 22:01:08
问题 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

Using jquery tokeninput and acts_as_taggable_on

被刻印的时光 ゝ 提交于 2019-12-04 13:56:35
问题 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

Showing only the most popular tags in the acts_as_taggable_on tag cloud

◇◆丶佛笑我妖孽 提交于 2019-12-04 07:13:15
Acts-as-taggable works great and everything but I was wondering if there was a way to restrict the tag cloud to only the most popular tags? Right not it looks like its ordering my cloud by the order in which the tags were created. But it makes more sense to have the tag cloud show only the most popular tags. My controller has: def styles_tag_cloud @tags = Tattoo.tag_counts_on(:styles).limit(40) end and my view has: <% tag_cloud(styles_tag_cloud, %w(css1 css2 css3 css4)) do |tag, css_class| %> <%= link_to tag.name, { :action => :tagged, :controller =>:index, :id => tag.name }, :class => css