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

  • SEARCH
  • Home
  • 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 7560597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:56:37+00:00 2026-05-30T12:56:37+00:00

I have a problem with the normal way rails operates when using nested forms

  • 0

I have a problem with the normal way rails operates when using nested forms / resources and routing.

I have two tables, Words and Definitions…

Words have many definitions, but I do not create a Word until it has at least one definition.

Everything on the model and controller end works but I cannot figure out how to handle the form helpers.

<%= semantic_form_for [@word, @definition] do |f| %>

This works perfectly but only if @word actually exists and is not a new UNSAVED record. IE in the controller I am doing a find_or_initialize_by call for Word then building a definition off of that.

<%= semantic_form_for [:word, @definition] do |f| %>

This words but only if the word doesn’t exist. IE if I try to edit using this construction I get an odd url (which doesn’t work). words/12345/definition/12345

I tried using the url_for helper but had similar results as above…

Any other ideas?

  • 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-30T12:56:38+00:00Added an answer on May 30, 2026 at 12:56 pm

    Mongoid doesn’t initialize embedded documents by default. You need to build them yourself most likely with a callback in your Word model:

    after_initialize :build_definition
    
    def build_definition
      self.definitions.build unless self.definitions.any?
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a peculiar problem. I created a normal Objective C class called SampleTable.
I have problem creating new instance of excel 2007 using VBA (from Access 2002).
I am starting using FMOD API and I have got problem with sound playing.
when using PRISM the normal way to hookup things with unity is to define
I have problem with one of my validation regex when using nonstandard utf-8 character.
I have a problem using a given CSS file I don't want to change.
I have a question about relationships between two tables. Let's say we have a
i´m a newbie to rails and have a problem with my associated object not
i have problem when i want to change element of set by using iterator.
I have problem in some JavaScript that I am writing where the Switch statement

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.