[Rails] Re: Noob: Child records not saved
Gerard Petersen (Planet)
gerardjpetersen at planet.nl
Tue Jan 10 16:42:35 GMT 2006
Guys,
A friggin' typo. It was the difference in column names in the database. Leaves
me with another discussion. Would I consider "first name" one or to words ..
@-)
No seriously. It gets tricky now. The source of the copied fname and lname the
contact. Has a belongs_to to a table called company. Of which I also want the
name.
Don't need you to work for me .. :-)
But should I then invoke a @company = Company.new to end up with something
like
@project.project_contact["company_name"] = contact.company['name']
Anyway .. Thanx a lot for your brainpower.
Regards,
Gerard
On Tuesday 10 January 2006 17:27, Gerard tried to type something like:
> Jules / Duane,
>
> @Jules: I tried it with the one first save disabled, but no luck.
>
> This is a breakpoint snap from @project, which tells something.
>
> => #<Project:0x40bf22b0 @new_record=false,
> @project_contact=#<ProjectContact:0x40bf07a8 @new_record=false,
> @errors=#<ActiveRecord::Errors:0x40be2ef0 @errors={},
> @base=#<ProjectContact:0x40bf07a8 ...>>, @attributes={"project_id"=>60,
> "company_name"=>"", "id"=>29, "lastname"=>"van dattum",
> "firstname"=>"saartje", "first_name"=>"", "last_name"=>""}>,
> @errors=#<ActiveRecord::Errors:0x40be8544 @errors={},
> @base=#<Project:0x40bf22b0 ...>>, @new_record_before_save=false,
> @attributes={"project_description"=>"daaro", "id"=>60,
> "project_name"=>"waaro"}>
>
> The interesting part is this.
>
> @attributes={"project_id"=>60, "company_name"=>"", "id"=>29,
> "lastname"=>"van dattum", "firstname"=>"saartje", "first_name"=>"",
> "last_name"=>""}
>
> First name and last name are in there twice. Once with and once without the
> underscore. But I'm afraid I don't know which stands for which. The table
> names are, with underscores as Rails expects them.
>
> Regards.
>
> Gerard.
>
> On Tuesday 10 January 2006 17:09, Jules Jacobs tried to type something like:
> > I think Rails checks the project_contact as saved here:
> >
> > @project.project_contact.save
> >
> > So Rails thinks it's already saved here:
> >
> > @project.save
More information about the Rails
mailing list