I have:
class Company < ActiveRecord::Base
has_many :categorizations
has_many :categories, :through => :categorizations
rails c
irb(main):003:0> comp=Company.find 1
Company Load (2.0ms) SELECT "companies".* FROM
"companies" WHERE
"companies"."id" = 1 LIMIT 1
=> #<Company id: 1, name: "company-1", vat_number:
"11111111112",
fiscal_code: "1111111111111112", address: "company-1",
street_number:
"1", zip_code: "11112", city: "company-1", prov:
"CA",
elected_address: "", elected_street_number: "",
elected_zip_code: "",
elected_city: "", elected_prov: "", tel: "", fax:
"", email: "",
website: "", reports: "prova", notes: "",
created_at: "2012-01-16
10:19:16", updated_at: "2012-01-16 11:43:40">
rb(main):004:0> comp.categorizations
Categorization Load (1.0ms) SELECT "categorizations".* FROM
"categorizations" WHERE
"categorizations"."company_id" = 1
=> [#<Categorization id: 101, company_id: 1, category_id: 1,
classification_id: nil, amount: nil, created_at: "2012-01-17
08:31:41", updated_at: "2012-01-17 08:31:41">,
#<Categorization id: 1,
company_id: 1, category_id: 2, classification_id: nil, amount:
#<BigDecimal:7b4b3d0e,''4.0'',1(4)>, created_at:
"2012-01-16 10:19:17",
updated_at: "2012-01-17 08:56:42">]
As you see comp has two categorizations.
In the form I have:
= semantic_form_for @company do |f|
= f.inputs do
= f.input :categories, :input_html => { :multiple => true, :id =>
"cat"}
= f.inputs :name, :vat_number, :fiscal_code, :city, :prov, :address,
:street_number, :elected_zip_code, :elected_city
= f.inputs :elected_prov, :elected_address, :elected_street_number,
:tel, :fax, :email, :website, :reports, :notes
= semantic_fields_for :categorizations do |cat|
= cat.inputs :id
I would expect to see the two categorizations id, instead I see nothing.
Does not fields_for iterate over categorizations fields and show their values?
--
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.