Hi All, I’m having trouble getting the
results filtered correctly, and I think that the answer is
straightforward for someone who knows what they are doing. So I’m
someone can help me.
I have two models: users and recipes. Recipes is the model that
acts_as_taggable with two contexts.
class User < ActiveRecord::Base
class Recipe < ActiveRecord::Base
acts_as_taggable_on :ingredients, :descriptions
the controller - this is meant to show a tag cloud (@tags), and then
tag is selected, the page reloads filtering out words based on the user
@user = current_user
if params[:tag] @recipes = Recipe.tagged_with(params[:tag]) else @recipes = Recipe.where("user_id =?", @user) end
The issue I’m having is that the results are filtered out by tag, but
doesn’t take in consideration the user or the context. For example, if
tag is “chicken”, it will show the results whether the tag is an
ingredients or descriptions tag, and it will show for all users.
I have tried to replace this line in the controller:
@recipes = Recipe.tagged_with(params[:tag])
with each, these variations to no avail:
(1) Filters the results by user, but doesn’t distinguish between
ingredients or descriptions tag
(2) Yields undefined method “set_owner_tag_list_on” for
@user.tag(@tagged_recipes, :with => (params[:tag]), :on => :ingredients)