Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Problem passing id of parent model to child

Received: by 10.59.0.234 with SMTP id bb10mr10578078ved.32.1351804348561;
        Thu, 01 Nov 2012 14:12:28 -0700 (PDT)
X-BeenThere: rubyonrails-talk@googlegroups.com
Received: by 10.52.65.108 with SMTP id w12ls2962937vds.4.gmail; Thu, 01 Nov
 2012 14:12:01 -0700 (PDT)
Received: by 10.52.20.51 with SMTP id k19mr7939951vde.4.1351804321062;
        Thu, 01 Nov 2012 14:12:01 -0700 (PDT)
Date: Thu, 1 Nov 2012 14:12:00 -0700 (PDT)
From: Linus Pettersson <linus.petters...@gmail.com>
To: rubyonrails-talk@googlegroups.com
Message-Id: <fcc430c5-fa2b-49d7-b2d6-8a1294bc5381@googlegroups.com>
In-Reply-To: <d78dc52f-cea0-4f91-b514-5f69b5ebc048@googlegroups.com>
References: <d78dc52f-cea0-4f91-b514-5f69b5ebc048@googlegroups.com>
Subject: Re: Problem passing id of parent model to child
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_1895_10545702.1351804320791"

------=_Part_1895_10545702.1351804320791
Content-Type: multipart/alternative; 
	boundary="----=_Part_1896_7109812.1351804320791"

------=_Part_1896_7109812.1351804320791
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

What path do you get? It should be something like 
"/organizations/:id/projects/new". This is where you can add a form for 
example to add a new project.

Do you try to POST to that path above? If so, that's wrong (it's for GET 
requests). Read more about nested resources here:
http://guides.rubyonrails.org/routing.html#nested-resources

//Linus


Den torsdagen den 1:e november 2012 kl. 22:02:36 UTC+1 skrev why-el:
>
> Hey fellas,
>
> I have an Organization model with many projects. I have a link to a new 
> project from the organization's show view, like so: 
> new_organization_project_path (@organization). I was hoping Rails would get 
> the id of the organization from the instance I am passing and populate 
> project.organization_id, but to no avail. The db rollbacks back and get 
> redirected to the new project page. Any ideas? How would you normally do 
> this? 
>
> Best, 
>

------=_Part_1896_7109812.1351804320791
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

<div>What path do you get? It should be something like "/organizations/:id/=
projects/new". This is where you can add a form for example to add a new pr=
oject.</div><div><br></div><div>Do you try to POST to that path above? If s=
o, that's wrong (it's for GET requests). Read more about nested resources h=
ere:</div><div>http://guides.rubyonrails.org/routing.html#nested-resources<=
br></div><div><br></div><div>//Linus</div><div><br></div><div><br>Den torsd=
agen den 1:e november 2012 kl. 22:02:36 UTC+1 skrev why-el:<blockquote clas=
s=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #c=
cc solid;padding-left: 1ex;">Hey fellas,<div><br></div><div>I have an Organ=
ization model with many projects. I have a link to a new project from the o=
rganization's show view, like so: new_organization_project_path (@organizat=
ion). I was hoping Rails would get the id of the organization from the inst=
ance I am passing and populate project.organization_id, but to no avail. Th=
e db rollbacks back and get redirected to the new project page. Any ideas? =
How would you normally do this?&nbsp;</div><div><br></div><div>Best,&nbsp;<=
/div></blockquote></div>
------=_Part_1896_7109812.1351804320791--

------=_Part_1895_10545702.1351804320791--