views:

344

answers:

1

Hello,

I'm trying to find the best solution:

I have a usermodel and the user should be able to save the keywords (multiple contexts) which he is interested at.

F.e.

User-interessts:

Sports: Checkbox(CB) fishing, CB Skyying, CB Tennis, CB Soccer

Music: CB Metal, CB Techno, CB Folk, CB Charts, ...

and so on...

After the user saves his selection, I would like to offer following search-functionality:

find by main category(input: sports, music,....)

find by keyword (input: sports, music, metal, fishing,....)

find by most viewed (show data with the most associated users)

and i would like to have a auto generated tag-cloud (like acts_as_taggable_on provides)

Beside this, it would be cool if the lists were easyly to administrate - Tags for example can't be used as main and subcategories (maybe this works with tag_contexts)...?

I tried this to build up with acts_as_tree, but this wasnt limited. Then I tried it with acts as taggable, but I dont get it, how i can access the tags model (there is no tag.rb file in my models folder).

Can you help me? Have you a better solution?

Thanks

+1  A: 

That sounds almost exactly like what "acts-as-taggable-on" provides.

From the readme:

class User < ActiveRecord::Base
  acts_as_taggable_on :tags, :skills, :interests
end

@user = User.new(:name => "Bobby")
@user.tag_list = "awesome, slick, hefty"      # this should be familiar
@user.skill_list = "joking, clowning, boxing" # but you can do it for any context!
@user.skill_list # => ["joking","clowning","boxing"] as TagList
@user.save

@user.tags # => [<Tag name:"awesome">,%lt;Tag name:"slick">,<Tag name:"hefty">]
@user.skills # => [<Tag name:"joking">,<Tag name:"clowning">,<Tag name:"boxing">]

# example finds:
User.tagged_with("awesome", :on => :tags) # => [@user]
User.tagged_with("awesome", :on => :skills) # => []
spirc