[Rails] Is "Pro Active Record: Databases with Ruby and Rails " still useable?

2011-04-12 Thread John Catalyne
I was thinking of buying the above mentioned book, but since it's from 2007, I thought it would be wiser to ask here if I can still make use of the things in it, or are they too outdated? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Go

[Rails] Re: What am I doing wrong in this nested form?

2011-04-07 Thread John Catalyne
But, how would having it as a virtual attribute help? It would not be saved to the database, so it's value would be lost. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group,

[Rails] Re: What am I doing wrong in this nested form?

2011-04-07 Thread John Catalyne
If I try to pass an User instance, the select isn't displayed. Here's the view now: <%= form_for @user,:url => users_path,:method => :post do |f| %> <%= f.fields_for :city do |b| %> <%= b.collection_select :id,City.all,:id,:name %> <% end %> <%= f.label :name %> <%= f.text_fie

[Rails] Re: What am I doing wrong in this nested form?

2011-04-07 Thread John Catalyne
Ignore the model names and what they stand for :). They are only for example purpose. So, if I make my view like this: <%= form_for :user,:url => users_path,:method => :post do |f| %> <%= f.fields_for :city do |b| %> <%= b.collection_select :id,City.all,:id,:name %> <% end %> <%=

[Rails] Re: What am I doing wrong in this nested form?

2011-04-07 Thread John Catalyne
If I put f.fields_for :city, this gets generated: and I get an AssociationMismatch saying ActiveRecord::AssociationTypeMismatch: City(#36862620) expected, got Hash(#21169932) If I put f.fields_for :city_attributes, this gets generated: Which looks more like what the nested form would accept

[Rails] What am I doing wrong in this nested form?

2011-04-07 Thread John Catalyne
I have these 2 models: class User < ActiveRecord::Base has_one :city accepts_nested_attributes_for :city end class City < ActiveRecord::Base belongs_to :user end This view: <%= form_for :user,:url => users_path,:method => :post do |f| %> <%= f.fields_for :city_attributes do |b| %> <