Humberto Ribeiro
2010-Nov-28 16:29 UTC
has_one accepts_nested_attributes_for fields_for NOT WORKING HELP
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? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Walter Lee Davis
2010-Nov-28 16:41 UTC
Re: has_one accepts_nested_attributes_for fields_for NOT WORKING HELP
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Humberto Ribeiro
2010-Nov-28 16:50 UTC
Re: has_one accepts_nested_attributes_for fields_for NOT WORKING HELP
Model address has 8 attributes... i did it to minimize user table size. About the problem... just try in your machine you will se it not workin as should do. On 28 nov, 13:41, Walter Lee Davis <wa...-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote:> 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 > > -e4hMzJ1U7sQq8ddH4TG6mw@public.gmane.org_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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
ssmithstone
2010-Nov-28 17:51 UTC
Re: has_one accepts_nested_attributes_for fields_for NOT WORKING HELP
in your def new try @user.address = Address.new On Nov 28, 4:50 pm, Humberto Ribeiro <prince...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Model address has 8 attributes... i did it to minimize user table > size. > > About the problem... just try in your machine you will se it not > workin as should do. > > On 28 nov, 13:41, Walter Lee Davis <wa...-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote: > > > > > > > > > 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 > > > -e4hMzJ1U7sQq8ddH4TG6mw@public.gmane.org_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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
Humberto Ribeiro
2010-Nov-29 05:08 UTC
Re: has_one accepts_nested_attributes_for fields_for NOT WORKING HELP
The result is the same... the field do not show in view when browsing to /users/new On 28 nov, 14:51, ssmithstone <stephen.smithst...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> in your > > def new > > try @user.address = Address.new > > On Nov 28, 4:50 pm, Humberto Ribeiro <prince...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Model address has 8 attributes... i did it to minimize user table > > size. > > > About the problem... just try in your machine you will se it not > > workin as should do. > > > On 28 nov, 13:41, Walter Lee Davis <wa...-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote: > > > > 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 > > > > -e4hMzJ1U7sQq8ddH4TG6mw@public.gmane.org_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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
tundrax
2010-Nov-29 07:55 UTC
Re: has_one accepts_nested_attributes_for fields_for NOT WORKING HELP
Just tested. Everything works fine. Make sure: 1) you didn''t forget to put "belongs_to :user" association in your Address model 2) use "<%=" for your "f.fields_for :address" in the _form view file. Hope this helps. On Nov 29, 2:08 pm, Humberto Ribeiro <prince...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> The result is the same... the field do not show in view when browsing > to /users/new > > On 28 nov, 14:51, ssmithstone <stephen.smithst...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > in your > > > def new > > > try @user.address = Address.new > > > On Nov 28, 4:50 pm, Humberto Ribeiro <prince...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Model address has 8 attributes... i did it to minimize user table > > > size. > > > > About the problem... just try in your machine you will se it not > > > workin as should do. > > > > On 28 nov, 13:41, Walter Lee Davis <wa...-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote: > > > > > 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 > > > > > -e4hMzJ1U7sQq8ddH4TG6mw@public.gmane.org_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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
tundrax
2010-Nov-29 08:00 UTC
Re: has_one accepts_nested_attributes_for fields_for NOT WORKING HELP
Section 7.4.2 of http://guides.rubyonrails.org/3_0_release_notes.html On Nov 29, 2:08 pm, Humberto Ribeiro <prince...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> The result is the same... the field do not show in view when browsing > to /users/new > > On 28 nov, 14:51, ssmithstone <stephen.smithst...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > in your > > > def new > > > try @user.address = Address.new > > > On Nov 28, 4:50 pm, Humberto Ribeiro <prince...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Model address has 8 attributes... i did it to minimize user table > > > size. > > > > About the problem... just try in your machine you will se it not > > > workin as should do. > > > > On 28 nov, 13:41, Walter Lee Davis <wa...-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote: > > > > > 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 > > > > > -e4hMzJ1U7sQq8ddH4TG6mw@public.gmane.org_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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
Seemingly Similar Threads
- accepts_nested_attributes_for and fields_for not working!
- accepts_nested_attributes_for :reject_if issue
- 'double' nest form fields with accepts_nested_attributes_for
- accepts_nested_attributes_for with has_many => :through
- nested_form gem don't work for accepts_nested_attributes_for :limit