What are the best solutions for Tagging in Rail with MongoID?
It seems that this is really simple, just add a hash or array to a document, but I'm not sure that this is the best way.
Maybe some gem? Or a simple move with nested documents?
For now, I used a very simple approach, which works very well : Just add an This works, but I still have some doubts about the display of the image. I think there can be a better solution / less for that map, but it has not been found yet. array - field
#app / model / image Monogead in RB Class image :: Documentation includes: Mongaid :: Timestamp Field: Message, Type = & gt; String field: tag, type = & gt; Array def self.images_for tag image.any_in (: tag => [tag]) end # routes.rb match "tag /: tag" = & gt; "Images # tag" # / app / controller / image_controllerRb Classroom Image Controller & lt; ApplicationController # GET / Tag # GET /tag.xml def tag @images = Image.images_for params [: tags] response_to do | Format | Format.html {Render "Index"} format.xml {Render: xml = & gt; @images} End End
Comments
Post a Comment