Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

multiple nested forms are unable to update child elements #19

Open
ghost opened this issue May 2, 2012 · 1 comment
Open

multiple nested forms are unable to update child elements #19

ghost opened this issue May 2, 2012 · 1 comment

Comments

@ghost
Copy link

ghost commented May 2, 2012

Hello Ryan

I am working on a survey app. where Survey has_many questions and question has_many options. Pretty much same as from your example.

everything works while creating the survey. it creates Survey, Questions and Options. But when updating.. it doesnt update Options for a given question.

I am using Rails 2.3.14
actionmailer (2.3.14)
actionpack (2.3.14)
activerecord (2.3.14)
activeresource (2.3.14)
activesupport (2.3.14)
Ascii85 (1.0.1)
attr_encrypted (1.1.2)
builder (3.0.0)
bundler (1.1.3, 1.0.18, 1.0.17)
daemons (1.0.10)
delayed_job (2.0.7, 1.8.5)
eigenclass (1.1.1)
encryptor (1.1.3)
factory_girl (2.6.3)
faker (1.0.1)
fastercsv (1.5.4)
haml (3.1.4)
hoptoad_notifier (2.4.11)
htmlentities (4.3.1)
httparty (0.8.1)
i18n (0.4.2)
json (1.7.0)
mail (2.4.3)
metaclass (0.0.1)
mime-types (1.17.2)
mocha (0.10.5)
multi_json (1.1.0)
multi_xml (0.4.2)
nokogiri (1.5.2)
oauth (0.4.5)
pdf-reader (1.0.0)
pg (0.13.2)
polyglot (0.3.3)
prawn (0.12.0)
rack (1.1.3)
rails (2.3.14)
rake (0.9.2.2, 0.9.2)
RedCloth (4.2.9)
right_aws (3.0.3)
right_http_connection (1.3.0)
ruby-net-ldap (0.0.4)
ruby-ole (1.2.11.3)
ruby-rc4 (0.1.5)
sanitize (2.0.3)
settingslogic (2.0.8)
spreadsheet (0.6.8)
state_machine (1.1.2)
tiny_mce (0.1.8)
treetop (1.4.10)
truncate_html (0.3.2)
ttfunk (1.0.3)

and rubygem version is 1.8.6

my codebase matches exactly with your episode 196.

params looks OK as well. not sure what this could be. you think version of rubygems can make a difference?

Ajit

@ghost
Copy link
Author

ghost commented May 2, 2012

this solution worked:

def update
questions = params[:survey].delete(:questions_attributes)

@survey = Survey.find(params[:id])

if @survey.update_attributes(params[:survey])
  @survey.update_attributes(:questions_attributes => questions)
  redirect_to edit_survey_path(@survey)
else
  render :action => :edit
end

end

any idea why @survey.update_attributes(params[:survey]) is not working but above method is?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants