Im stumped. I followed Ryan B. screencast 73 and had this working
the other day for an assets model. Today im trying to implement the
same thing for a case_study model that belongs_to :services.
MODEL: CaseStudy
belongs_to :services
MODEL: Services
has_many :case_studies, :dependent => :destroy
def case_studies=(case_studies)
case_studies.each do |attribute|
case_studies.build(attribute)
end
end
CONTROLLER: new method
@service.case_studies.build
in my _form partial for services
<% form_for(@service, :html => {:multipart => true}) do |f| %>
…
(this is the nested part)
<% for case_study in @service.case_studies %>
<% fields_for “service[case_studies][]”, case_study do |
case_study_form|%>
<%= case_study_form.label :title %>
<%= case_study_form.text_field :title %>
<%= case_study_form.label :description %>
<%= case_study_form.text_area :description, :rows =>
5, :cols => 29 %>
<%= case_study_form.label :permalink %>
<%= case_study_form.text_field :permalink %>
<%= case_study_form.label :keywords %>
<%= case_study_form.text_field :keywords %>
<%= case_study_form.label “Add Case Study” %>
<%= case_study_form.file_field :attachment, :size => 16 %>
<% end %>
<% end %>
…
<% end %>
This is where its weird. I can raise the params and it shows the hash,
but it adds a [-] hash to the case_studies hash.
all the form fields are named service[case_studies][-][attr etc…]
when i view the source
any help here?
Thanks in advance
Bob