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 685641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:56:35+00:00 2026-05-14T01:56:35+00:00

I am working on a pretty simple web application (famous last words) and am

  • 0

I am working on a pretty simple web application (famous last words) and am working with Rails 2.3.5 + MongoMapper 0.7.2 and using embedded documents. I have two questions to ask:

First, are there any example applications out there using Rails + MongoMapper + EmbeddedDocument? Preferably on GitHub or some other similar site so that I can take a look at the source and see where I am supposed to head? If not …

… what is the best way to approach this task? How would I go about creating a form to handle an embedded document.

What I am attempting to do is add addresses to users. I can toss up the two models in question if you would like.

Thanks for the help!

  • 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-14T01:56:36+00:00Added an answer on May 14, 2026 at 1:56 am

    Here’s the basic approach I took in one of my apps. Problem has many answers – problem is a document, answer is an embedded document. You can use the “add answer” link to generate another answer field, and the “remove” link to delete one.

    _form.html.erb:

    <% form_for @problem do |f| %>
      <%= f.error_messages %>
    
      <p>
        <%= f.label :content %><br />
        <%= f.text_area :content, :size => '50x7' %>
      </p>
    
      ...etc...
    
      <%= add_answer_link "(add answer)" %>
      <div id="answers">
        <%= render :partial => 'answer', :collection => @problem.answers %>
      </div>
    
      <p><%= f.submit "Submit" %></p>
    <% end %>
    

    _answer.html.erb:

    <div class="answer">
      <% fields_for 'problem[answers]', answer, :index => nil do |f| -%>
        <%= f.label :content, "Answer #{answer.id}:" %>
        <%= f.text_field :content, :size => 50 %>
        <%= link_to_function "(remove)", "$(this).up('.answer').remove()" %>
      <% end -%>
    </div>
    

    problems_helper.rb

    module ProblemsHelper
      def add_answer_link(name)
        link_to_function name do |page|
          page.insert_html :bottom, "answers", :partial => 'answer', :object => Answer.new
        end
      end
    end
    

    I cut out a couple minor bits of the implementation, but that should work.

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

Sidebar

Related Questions

I have pretty much finished my first working Symbian application, but in my hastened
I'm working on a large scale performance critical asp web application with a pretty
I just started working for a pretty large company and my group manages all
I'm working on what I think is a pretty standard django site, but am
I'm currently working with Groovy and Grails. While Groovy is pretty straight-forward since it's
Working with dates in ruby and rails on windows, I'm having problems with pre-epoch
Working on a project at the moment and we have to implement soft deletion
Working with a SqlCommand in C# I've created a query that contains a IN
Working on a somewhat complex page for configuring customers at work. The setup is
Working on a project that parses a log of events, and then updates a

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.