Ruby on Rails Sunday, November 28, 2010

On Nov 28, 2010, at 11:29 AM, Humberto Ribeiro wrote:

>
> MODEL
> class User < ActiveRecord::Base
> has_one :address, :dependent => :destroy
> accepts_nested_attributes_for :address
> end
>
> CONTROL
> def new
> @user = User.new
> @user.build_address # Adicionei
> ...
>
> VIEW partial _form
> ....
> <% f.fields_for :address do |b| %> # Adicionei
> <%= b.text_field :city_manual %> # Adicionei
> <% end %> # Adicionei
> ....
>
> So this is not working... when browser to users/new it do not show the
> field as should...
> Change this to a has_many all works.
> Using has_one this make me crazy and not work... anyone help?

Sorry, I don't have an answer for you on this. But I'm curious -- why
are you putting the address in a separate model if you are using
has_one? It seems like an over-normailization to me. Why not just put
those attributes in the user and be done with it?

Walter

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment