Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4115210
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:33:10+00:00 2026-05-20T22:33:10+00:00

What are good solutions for tagging in Rails with MongoID? It seems that it

  • 0

What are good solutions for tagging in Rails with MongoID?

It seems that it is really simple to just add a hash or array to a document, but I am not sure if that is the best approach.

Maybe some Gem? Or a simple trick with nested documents?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T22:33:11+00:00Added an answer on May 20, 2026 at 10:33 pm

    For now, I used a very simple approach, that works very well: Just include an Array-field.

    #app/models/image.rb
    class Image
      include Mongoid::Document
      include Mongoid::Timestamps
    
      field :message, :type => String
      field :tags, :type => Array
    
      def self.images_for tag
        Image.any_in(:tags => [tag])
      end
    end
    
    #routes.rb
    match "tag/:tag" => "images#tag"
    
    #/app/controller/images_controller.rb
    class ImagesController < ApplicationController
      # GET /tag
      # GET /tag.xml
      def tag
        @images = Image.images_for params[:tag]
    
        respond_to do |format|
          format.html { render "index" }
          format.xml  { render :xml => @images }
        end
      end
    end
    

    This works, but I am a still a little doubtfull about the performance of the Image.any_in map/reduce. I think there may be a better solution for that map/reduce but have not found it, yet.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found some really good solutions alike : CollabNet (on grails) and others But
I have no really found any good solutions yet I have a Rails 3
I have tried to search for similar problems, but not found any good solutions.
I've searched the Internet and have found some good solutions for teeing STDOUT to
I'm working on making some code using metaheuristics for finding good solutions to the
Are there any good technical solutions for extremely long term archiving of data, for
So I've been looking for a good solution everywhere but did not find anything
Are there any good solutions out there for TDD of a MacOSX Objective-c app?
Does anyone know of any good solutions (Eclipse plugins presumably) for using Eclipse to
I searched around and doesn't seem to have any good solutions. The closest one:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.