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
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,
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
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 %>
<%=
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
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| %>
<
6 matches
Mail list logo