Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm a noob, but i think i can help - not for the view part, but for the logic beneath. </p> <p>It seems you will need an action in your PersonPagesController that will be called on form submission (admitting that your form sends a person_name and a project_name), that should look like :</p> <pre><code>def add_person_to_project @person = Person.find(params[:person_name]) @project = Project.find_or_create_by_name(params[:project_name]) @project.persons &lt;&lt; @person # or @person.projects &lt;&lt; @project end </code></pre> <p>information on find_or_create can be found there <a href="http://api.rubyonrails.org/classes/ActiveRecord/Base.html" rel="nofollow">http://api.rubyonrails.org/classes/ActiveRecord/Base.html</a> (under "Dynamic Attribute-based Finders")</p> <p>you will obviously have to send the person's name with the form for this to work, which you should be able to do by adding a pre-filled hidden field when generating the empty form for a specific person (i don't know formstatic and nested_form though...). You may also want to secure this a bit ( check if a person is really found, and if that person does not already belong to the project before adding it...)</p> <p>Also, i would generally not advise to use the name fields as keys for your persons and projects, but that's up to you. I would advise, though, that you implement this another way, letting the user choose the project in a list or create a new one (what happens if your user makes a typo for example ?)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload