> When filling an id column like that you should probably be passing an
> id rather than a Provider object (although :provider =>
> Provider.find_by_name(...) should be ok).
> Sounds like you should break this down into smaller steps so that you
> see where it is going wrong (eg so that you can check whether a
> provider is being found at all)
I also thought that and finaly did the trick! Now I do something like:
FasterCSV.foreach("importdata/tarife.csv", :headers =>
true, :col_sep => ',') do |row|
Anbieter.find_or_create_by_name( :name =>row['Anbieter_Name'] )
associated_anbieter =
Anbieter.find_by_name(row['Anbieter_Name'])
associated_kategorie =
Kategorie.find_by_name(row['Kategorie'])
associated_netz = Netz.find_by_name(row['Netz'])
Tarif.create(
:anbieter_id => associated_anbieter.id,
:kategorie_id => associated_kategorie.id,
:netz_id => associated_netz.id,
:name => row['Tarif_Name'] )
end
Probably not really a beauty but working. Anyway thanks for your
feedback.
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.