j'ai un modele USer
class User < ActiveRecord::Base
has_one :account
accepts_nested_attributes_for :account, :allow_destroy => true
validates_associated :account
attr_accessible :account_attributes
je met à jour en utilisant une Nested Form, et ça marche les validations
sont effectuées et les records sont mis à jour, MAIS au redisplay les
valeurs des records ne sont pas affichés dans les champs
ex: le prénom n'est pas affiché et pourtant il est enregistré après
modification
#<User id: 1, email: "yves@somewhere.com", ..
#<Account id: 4, user_id: 1, title: 0, first_name: "Yves", ...
ma View
...
<% form_for :user, :url => { :action => "update" } do |user_form|
%>
<% user_form.fields_for :account_attributes do |account_fields| %>
<li>
<label for="user_firstname">First Name</label>
<%= account_fields.text_field :first_name, :size => "30" %>
</li>
.....
qu'est-ce qui est faux dans cette vue ? merci de vos indications..
on 2009-07-02 00:11
on 2009-07-02 11:02
Le 2 juil. 09 à 00:11, Kad Kerforn a écrit : > validations > <% form_for :user, :url => { :action => "update" } do |user_form| > %> > <% user_form.fields_for :account_attributes do |account_fields| > %> => Je ferais plutôt<% user_form.fields_for :accounts do |account_field| %> En effet account_attributes n'est pas défini. Par contre accounts l'est. -- Cyril Mougel http://blog.shingara.fr
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.