Greetings all. I''m having problems with a belongs_to not reporting the *correct* info. >> p = Patient.new => #<Patient:0x26284e0 @new_record=true, @attributes= {"work_phone"=>nil, "city"=>nil, "postal_code"=>nil, "ACRES"=>nil, "health_insurance_province_id"=>nil, "province_id"=>nil, "country_id"=>nil, "address_two"=>nil, "firstname"=>nil, "lastname"=>nil, "health_insurance_expiry"=>nil, "health_insurance_version"=>nil, "id_orig"=>0, "PROVIDNUM"=>nil, "work_extension"=>nil, "sex"=>nil, "health_insurance_number"=>nil, "home_phone"=>nil, "PROVIDNAME"=>nil, "date_of_birth"=>nil, "middle_initial"=>nil, "other_phone"=>nil, "address_one"=>nil, "health_insurance_prov"=>nil}> >> p.country_id = 100 #honduras => 100 >> p.country => #<Country:0x25a99d8 @attributes={"name_short"=>nil, "priority"=>"0", "name_long"=>"Honduras", "id"=>"100"}> >> p.country_id = 105 #Indonesia => 105 >> p.country => #<Country:0x25a99d8 @attributes={"name_short"=>nil, "priority"=>"0", "name_long"=>"Honduras", "id"=>"100"}> >> p.country_id => 105 wtf? why is Honduras returned as p.country? not honduras? class Patient < ActiveRecord::Base belongs_to :country ... I''m not aware of anything else that should impact the above symptom. Any ideas rails riders? It somehow seems that the relationship Country isn''t related to the attribute "country_id" ?? rails --version 1.1.6 cheers, Jodi --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Associations are cached. If after setting country_id to 105 you do p.country(true) then you should get the country you expect back Fed==red -- 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, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jodi Showers
2006-Nov-08 00:00 UTC
Re: belongs_to association not connected to FK attribute?
On 7-Nov-06, at 6:09 PM, Fred wrote:> > Associations are cached. If after setting country_id to 105 you do > p.country(true) then you should get the country you expect back > > Fed==redwow - learn something new every day. every-single-day Without much thought it seems to make sense that assigning a value to the FK really should suggest a cache clear on that association. Thanx for your help Fred. J --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---