問題タブ [acts-as-taggable-on]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票する
2 に答える
193 参照

ruby-on-rails - :anyフラグは、acts_as_taggable_onのtagged_withの:on(コンテキスト)フラグを上書きしますか?

私は、acts_as_taggable_onの「tagged_with」メソッドでフラグ:onと:anyがどのように連携するかについて混乱しています。

たとえば、次のユーザー@user1と@user2がある場合:

インタレストリストにあるすべてのユーザーにタグ["2"、 "50"]のいずれかを含めたい場合は、次のことを試しました。

問題は、@ user1(interest_listではなくskill_listに「2」が含まれている)が返されることですが、何も期待していませんでした。フラグ:anyがフラグ:onを上書きした可能性があります。上記のフィルターを実際に実行する方法はありますか?

また、副次的な質問は、メソッドで使用可能なすべてのフラグをどのように見つけるかということです。たとえば、taged_withには:on、:any、:match_all、...がありますが、それらすべてを一覧表示するにはどうすればよいですか?

皆さん、助けてくれてありがとう!

0 投票する
0 に答える
332 参照

mysql - act-as-taggable-on および select フィールド

Rails 3.0にActsAsTaggableOn gem を使用していますが、すべて正常に動作します。

現在、ActiveRecord でいくつかのフィールドのみを選択するいくつかのクエリを高速化しようとしています。

しかし、MySQL から次のエラーが返されました。

代わりに、コレクションで tag_counts を定期的に呼び出すと、次のように機能します。

宝石を編集せずに簡単な回避策のアイデアはありますか?

0 投票する
2 に答える
2580 参照

ruby-on-rails - Tagging with autocomplete in Rails

My (long, I apologize) question is a follow-on to: How to add tagging with autocomplete to an existing model in Rails?

I am using acts-as-taggable-on and rails3-jquery-autocomplete, and trying to set up a system (much like Stack Overflow) where users begin to enter in a tag and suggestions appear in a drop-down box.

Goal

I am in the answers#new form and I want to see a list of tags that relate to questions. i.e. Imagine being on SO looking for new Rails questions to answer, and searching for ra. Ruby-on-Rails pops up, you click it, and you see a list of questions under RoR, any one of which you can answer.

These are the steps I've taken.

  1. Installed both gems. Both seem to work on their own.
  2. Added <%= javascript_include_tag "ui/jquery.ui.position", "ui/jquery.ui.autocomplete", "autocomplete-rails.js", "rails.js", "application.js" %>. (I already have Jquery, UI Core and UI Effects.)
  3. Answers controller: I added at top autocomplete :question, :tags, :full => true. I also tried autocomplete :tag, :name, :full => true.
  4. Question.rb: acts_as_taggable_on :tags.
  5. View:
    <%= form_tag new_answer_url, :method => "get" do %>
    <%= autocomplete_field_tag "tag_list", 'tags', autocomplete_question_tags_answers_path %>
    <% end %>

A simple autocomplete (no tagging) works (but it only works once per page load). With tagging, no success.

Problems

With lots of experimentation (and many hours) I am getting these problems:

  1. I get NameError (unitialized constant Tag) in server response to initial entry.
  2. With a non-taggable implementation (searching for the simple question text itself) I get a JQuery Autocomplete-style drop-down but my cursors cannot access the options with up/down. I have to click them with the mouse. Also, the dropdown doesn't disappear unless I reload the page!
  3. After the server responds with results once (only non-taggable is working as I mentioned), it doesn't respond again to key presses or changes in the text entry.

I would greatly appreciate any help you are able to give. I have gone through a few tutorials step-by-step but no luck today.

0 投票する
2 に答える
3317 参照

ruby-on-rails - act_as_taggable_on で検索する

特定のタグを持つすべてのレコードのモデルを検索しようとしています。

検索しようとしているサンプル出力:

だから、好みや旅行などをQuestion持っています。tags私は試した:

params[:tags]たとえば、"refere" や "ences" の場合、トップ レコードを返すにはどうすればよいですか?

質問モデル

2 回目の試行

@Nashの提案に従ってクエリを変更しようとするカスタムコントローラーアクションを作成しました。どうすれば修正できますか?

フォームに「旅行」と入力すると、次のようになります。

Started GET "/answers/autocomplete_question_tags?term=travel" for 127.0.0.1 at 2011-04-16 20:37:34 -0400
Processing by AnswersController#autocomplete_question_tags as JSON
Parameters: {"term"=>"travel"}
{"term"=>"travel", "action"=>"autocomplete_question_tags", "controller"=>"answers"}
SQL (1.8ms) SHOW TABLES
SQL (0.8ms) SELECT COUNT(*) AS count_id FROM (SELECT 1 FROM 'questions' WHERE (questions.id IN (SELECT taggings.taggable_id FROM taggings JOIN tags ON taggings.tag_id = tags.id AND (tags.name LIKE '%travel') WHERE taggings.taggable_type = 'Question'))) AS subquery
logger.debug: 1 result in query
Completed in 114ms

ActionView::MissingTemplate (Missing template answers/autocomplete_question_tags with {:handlers=>[:erb, :rjs, :builder, :rhtml, :rxml, :haml], :formats=>[:json], :locale=>[:en, :en]} in view paths "/Users/san/Documents/san/apl/app/views",
app/controllers/answers_controller.rb:36:in 'autocomplete_question_tags'

Rendered /Users/san/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.1/lib/action_dispatch/middleware/templates/rescues/missing_template.erb within rescues/layout (0.7ms)

0 投票する
1 に答える
867 参照

ruby-on-rails - Acts-As-Taggable-On を使用したコールバック: Rails 3 の未定義メソッドは、Rails 2.3 で美しく動作します

このコールバック メソッドが Rails 2.3.x / Ruby 1.8.7 では機能するのに、Rails 3.0.x / Ruby 1.9.2 では機能しない理由を知っている人はいますか?

Rails 2.3.x / Ruby 1.8.7 で動作:

しかし、3.0.x / Ruby 1.9.2 では、投稿の作成時に次のエラーが表示されます。

私はacts-as-taggable-on2.0.6を使用しています。私の質問を読んでくれてありがとう。

0 投票する
1 に答える
958 参照

ruby-on-rails - フォーム (acts_as_taggable_on を使用) と Rails 3 からタグを入力するにはどうすればよいですか?

ここに私のフォームがあります:

Vendor.rbはacts_as_taggable_onです。

しかし、tag_list のフィールドに文字列を入力すると、コンソールに戻って vendor.tags を確認しても何も保存されません。

フォームからタグを入力できるようにするにはどうすればよいですか?

0 投票する
2 に答える
257 参照

ruby-on-rails - act_as_tggable_on URL に適したタグ名

act_as_taggable_on のタグ名を URL フレンドリにする方法はありますか?

たとえば、現時点では「tags/foo」と「tags/bar」がうまく機能しています。ただし、「rabbits foot」などの名前にスペースを追加すると、URL は「tags/rabbits%20foot」になります。その %20 をダッシュ​​に置き換えたいと思います。

前もって感謝します!

アップデート

stackoverflow が実際に、私が考えているものと非常によく似た、またはまったく同じ方法でタグを使用していることに気付きました。

0 投票する
1 に答える
227 参照

ruby-on-rails - Acts_as_taggable_onで使用されるタグの重複していないリストを生成するにはどうすればよいですか?

2部構成の質問:

私はacts_as_taggable_onを使用しており、特定のモデルのすべてのレコードで使用されるすべてのタグの配列を生成したいと考えています。しかし、私はそのリストに重複が含まれないようにしたい。

タグを選択すると、そのタグでタグ付けされたすべてのレコードのリストが生成されます。次に、そのレコードのリストに属する他のすべてのタグのリストを生成するにはどうすればよいですか(重複はありませんか?)

言い換えると、レコードのサブセットについて、関連するすべてのタグ(もちろん、そのサブセットを生成したタグを除く)を表示するにはどうすればよいですか?

0 投票する
1 に答える
387 参照

ruby-on-rails - タグのタイムスタンプの配列を更新する

このメソッドは、Acts_As_Taggable_On の tag_list 配列からすべてのタグの updated_at タイムスタンプを更新しますか?

Ruby 1.9.2、Rails 3.0.7、および Acts_As_Taggable_On gem を使用しています。

post.rb:

comment.rb: ( で簡略化touch)

tag.rb: (これは機能しません。必要な数のタグを作成できます。制限は無視されます)