Sonntag, 8. September 2013

The mistery of nested forms (III)

On last Friday, I read until the chapter "Writing ActiveRecord specifications" of the book "Instant RSpec Test-Driven Development How-to". I like this book because you can have a fast start for Rspec.

In the evening, Mathias solved some doubts that I had in the nested form view:
- The Task model is Mongo. I tried to use the method accepts_nested_attributes_for in this Model but it didn't work without has_many :vacancies. We didn't wanted this association, so I asked Mathias. The solution was that the Product::ClassifiedAdvertising::Task class in voluntary_classified_advertising implements the methods vacancies and vacancies_attributes=, so we don't need the method accepts_nested_attributes in our Task model to achieve the nested form between Task and Vacancy.

- Another doubt that I had is that the path to access the partial template "_vacancy_fields.html.erb" is "workflow/tasks/vacancy_fields". When I tried to access the partial template "_candidature_fields.html.erb" from "_vacancy_fields.html.erb", I had to use the path "products/types/classified_advertising/workflow/tasks/candidature_fields", although both templates are in the same directory. The solution is that we must implement a method "product" in candidature. This method allows to builds the relative path "products/types/classified_advertising/" for the partial template.

After that, I changed the view from a list of resources to a form for a resource, because what the client asked was a form and not a list. So an user can create a new Resource for an existing Vacancy. The problem is, as we saw in our last post, that Candidatures can't receive the attributes from Resources because there isn't a nested form between both Models. So we have to solve this problem the next day.

Keine Kommentare:

Kommentar veröffentlichen