Freitag, 6. September 2013

The mistery of nested forms (II)

Last night, after my last post, I continued working because I wanted to complete the update controller. So I studied nested forms with polymorphy. I read code from other developers using nested and polymorphy. And I was able to see that I was making a mistake.

If we want nested forms we have to use the following structure:

(Parent object) has many (children objects)*

I thought our relation was:

Tasks > Many vacancies > Many Candidatures > Many Resources

However, studying our schema and models I was able to see that this relation wasn't right. In fact was:

Tasks > Many vacancies > Many Candidatures

Resource > Many Candidatures

So, we can't apply a nested form from Candidature to Resource, because the parent object is resource and not candidature.

After that, I removed the nested form for resource and wrote a modification in the update controller. If we push the 'Accept' button, we change the state of candidature to :accepted. If we push the 'Deny' button, we change the candidature state to :denied

I have now a view that works, although it isn't finished.
    
* It can be also a has-one relation, but in our case is a has-many relation

Keine Kommentare:

Kommentar veröffentlichen