문제

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?

올바른 솔루션이 없습니다

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top