# Nested\_form

**URL:** <https://www.ruby-forum.com/t/nested-form/202972>\
**Category:** Rails\
**Created:** [February 9, 2011, 9:38pm UTC](https://www.ruby-forum.com/t/nested-form/202972 "2011-02-09T21:38:39Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [February 9, 2011, 9:38pm UTC](https://www.ruby-forum.com/t/nested-form/202972/1 "2011-02-09T21:38:39Z")

</div>

I’m trying to use the nested form gem from

> **[GitHub - madebydna/nested\_form: Rails plugin to conveniently handle multiple...](https://github.com/madebydna/nested_form)**
>
> Rails plugin to conveniently handle multiple models in a single form. - GitHub - madebydna/nested\_form: Rails plugin to conveniently handle multiple models in a single form.

However I’m getting undefined method `muscle\_id’ for  
#Muscle:0x00000004f6e0b0

My code can be found at [818944’s gists · GitHub](https://gist.github.com/818944)

best regards,  
Seb

---

<div class="post-metadata">

**Author:** ![seb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8edcca/32.png) [@seb](https://www.ruby-forum.com/u/seb)\
**Post date:** [February 9, 2011, 10:22pm UTC](https://www.ruby-forum.com/t/nested-form/202972/2 "2011-02-09T22:22:37Z")

</div>

On 9 February 2011 20:37, Seb [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m trying to use the nested form gem  
> fromhttps://github.com/madebydna/nested\_form  
> However I’m gettingundefined method `muscle\_id’ for  
> #Muscle:0x00000004f6e0b0  
> My code can be found athttps://gist.github.com/818944

What makes you think that the Muscle model has a method muscle\_id? Is  
there a column of that name in the muscles table?

Colin

---

<div class="post-metadata">

**Author:** ![seb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8edcca/32.png) [@seb](https://www.ruby-forum.com/u/seb)\
**Post date:** [February 9, 2011, 10:28pm UTC](https://www.ruby-forum.com/t/nested-form/202972/3 "2011-02-09T22:28:55Z")

</div>

On Wed, Feb 9, 2011 at 10:20 PM, Colin L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> On 9 February 2011 20:37, Seb [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > I’m trying to use the nested form gem  
> > fromhttps://github.com/madebydna/nested\_form  
> > However I’m gettingundefined method `muscle\_id’ for  
> > #Muscle:0x00000004f6e0b0  
> > My code can be found athttps://gist.github.com/818944
> 
> What makes you think that the Muscle model has a method muscle\_id? Is  
> there a column of that name in the muscles table?

No there isnt and I’m actually trying to id of the muscle in question  
which is associated through targets. Exercise has many muscles through  
targets… you got an idea about what to pass as argument instead?

---

<div class="post-metadata">

**Author:** ![seb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8edcca/32.png) [@seb](https://www.ruby-forum.com/u/seb)\
**Post date:** [February 9, 2011, 10:32pm UTC](https://www.ruby-forum.com/t/nested-form/202972/4 "2011-02-09T22:32:42Z")

</div>

On 9 February 2011 21:26, Sebastian [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > 
> 
> No there isnt and I’m actually trying to id of the muscle in question  
> which is associated through targets. Exercise has many muscles through  
> targets… you got an idea about what to pass as argument instead?

Looking briefly at the code you seem to have a Muscle object, so is it  
not just id that you want?

Colin

---

<div class="post-metadata">

**Author:** ![seb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8edcca/32.png) [@seb](https://www.ruby-forum.com/u/seb)\
**Post date:** [February 10, 2011, 10:09am UTC](https://www.ruby-forum.com/t/nested-form/202972/5 "2011-02-10T10:09:37Z")

</div>

On 9 February 2011 21:46, Sebastian [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> …  
> Actually that got me a bit furthere. Now the error is:  
> Couldn’t find Muscle with ID=3685340 for Exercise with ID=212831413
> 
> which is a bit strange because that is exactly the relation I’m trying  
> to have created. So ofcourse it doesnt exists.

Possibly you are trying to find the record before you have saved it.  
If you want help with that one I think you will have to show that bit  
of code that is causing the problem.

Do you know about ruby-debug that allows you to break into the code to  
inspect the data? See the Rails Guide on debugging if you have not  
used this previously.

Colin

---

<div class="post-metadata">

**Author:** ![seb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8edcca/32.png) [@seb](https://www.ruby-forum.com/u/seb)\
**Post date:** [February 9, 2011, 10:48pm UTC](https://www.ruby-forum.com/t/nested-form/202972/6 "2011-02-09T22:48:22Z")

</div>

On Wed, Feb 9, 2011 at 10:31 PM, Colin L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > > there a column of that name in the muscles table?
> > 
> > No there isnt and I’m actually trying to id of the muscle in question  
> > which is associated through targets. Exercise has many muscles through  
> > targets… you got an idea about what to pass as argument instead?
> 
> Looking briefly at the code you seem to have a Muscle object, so is it  
> not just id that you want?

Actually that got me a bit furthere. Now the error is:  
Couldn’t find Muscle with ID=3685340 for Exercise with ID=212831413

which is a bit strange because that is exactly the relation I’m trying  
to have created. So ofcourse it doesnt exists.

---

<div class="post-metadata">

**Author:** ![seb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8edcca/32.png) [@seb](https://www.ruby-forum.com/u/seb)\
**Post date:** [February 10, 2011, 11:51am UTC](https://www.ruby-forum.com/t/nested-form/202972/7 "2011-02-10T11:51:52Z")

</div>

On 10 February 2011 10:36, Sebastian [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > If you want help with that one I think you will have to show that bit  
> > have done for the last few days has been from teh gf’s laptop with  
> > putty as a entry point to my linux server with vim/rails/etc.
> 
> But also my reason for asking here instead of hitting the sources of  
> the gem in question is that I’m new to rails. So I dont think it would  
> do me much good here.

You did not say that you are getting the error within the gem code (or  
I missed it), I assumed it was in your code. I don’t see where you  
are using the gem in the code you posted.

Colin

---

<div class="post-metadata">

**Author:** ![seb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8edcca/32.png) [@seb](https://www.ruby-forum.com/u/seb)\
**Post date:** [February 10, 2011, 11:38am UTC](https://www.ruby-forum.com/t/nested-form/202972/8 "2011-02-10T11:38:43Z")

</div>

On Thu, Feb 10, 2011 at 10:07 AM, Colin L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> of code that is causing the problem.  
> [GitHub - madebydna/nested\_form: Rails plugin to conveniently handle multiple models in a single form. · GitHub](https://github.com/madebydna/nested_form) - I actually already wrote  
> the author about the issue since I belive it’s a bug.

> Do you know about ruby-debug that allows you to break into the code to  
> inspect the data? See the Rails Guide on debugging if you have not  
> used this previously.

Yeah, and I do need to get a better setup here. but the development I  
have done for the last few days has been from teh gf’s laptop with  
putty as a entry point to my linux server with vim/rails/etc.

But also my reason for asking here instead of hitting the sources of  
the gem in question is that I’m new to rails. So I dont think it would  
do me much good here.

---

<div class="post-metadata">

**Author:** ![seb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8edcca/32.png) [@seb](https://www.ruby-forum.com/u/seb)\
**Post date:** [February 10, 2011, 12:01pm UTC](https://www.ruby-forum.com/t/nested-form/202972/9 "2011-02-10T12:01:57Z")

</div>

On Thu, Feb 10, 2011 at 11:50 AM, Colin L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > > Possibly you are trying to find the record before you have saved it.  
> > > Yeah, and I do need to get a better setup here. but the development I

Sorry, my bad. The first error didnt originate from the gem. Thus I  
only pasted the original parts. Anyway here is the rest.

snot@rails3:~/fitfit$ cat app/views/exercises/\_form.haml | gist

> <https://gist.github.com/anonymous/820315>

snot@rails3:~/fitfit$ cat app/controllers/exercises\_controller.rb | gist

> <https://gist.github.com/anonymous/820317>

snot@rails3:~/fitfit$ cat app/models/exercise.rb | gist

> **[820318’s gists](https://gist.github.com/820318)**
>
> GitHub Gist: star and fork 820318's gists by creating an account on GitHub.

I hope that the above terminal out speaks for it self 🙂

---

<div class="post-metadata">

**Author:** ![seb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8edcca/32.png) [@seb](https://www.ruby-forum.com/u/seb)\
**Post date:** [February 10, 2011, 2:32pm UTC](https://www.ruby-forum.com/t/nested-form/202972/10 "2011-02-10T14:32:00Z")

</div>

On 10 February 2011 11:00, Sebastian [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > > >
> > 
> > are using the gem in the code you posted.  
> > [820318’s gists · GitHub](https://gist.github.com/820318)
> 
> I hope that the above terminal out speaks for it self 🙂

You have not shown the error and stack trace.

Colin

---

<div class="post-metadata">

**Author:** ![seb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8edcca/32.png) [@seb](https://www.ruby-forum.com/u/seb)\
**Post date:** [February 10, 2011, 3:59pm UTC](https://www.ruby-forum.com/t/nested-form/202972/11 "2011-02-10T15:59:27Z")

</div>

On 10 February 2011 14:35, Sebastian [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hope this isnt too annoying.

Just paste the error and stack trace here.

Colin

---

<div class="post-metadata">

**Author:** ![seb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8edcca/32.png) [@seb](https://www.ruby-forum.com/u/seb)\
**Post date:** [February 10, 2011, 3:37pm UTC](https://www.ruby-forum.com/t/nested-form/202972/12 "2011-02-10T15:37:24Z")

</div>

On Thu, Feb 10, 2011 at 2:30 PM, Colin L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > > > > > to have created. So ofcourse it doesnt exists.  
> > > > > > used this previously.  
> > > > > > I missed it), I assumed it was in your code. I don’t see where you  
> > > > > > snot@rails3:~/fitfit$ cat app/models/exercise.rb | gist  
> > > > > > [820318’s gists · GitHub](https://gist.github.com/820318)
> > 
> > I hope that the above terminal out speaks for it self 🙂
> 
> You have not shown the error and stack trace.

sorry, doing eight different things here…

I think it might be easier if you see it for yourself at the actual  
page.  
You can sign in with [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) and password ==  
“password” at  
[http://surfstation.dk:3000/exercises](http://surfstation.dk:3000/exercises)

if you try to add an exercise without any targets and then afterwards  
try to edit it and add targets you will see the error and trace.  
If you add a new exercise with targets you will see the same error  
where one of the id’s is missing.

Hope this isnt too annoying.

---

<div class="post-metadata">

**Author:** ![seb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8edcca/32.png) [@seb](https://www.ruby-forum.com/u/seb)\
**Post date:** [February 10, 2011, 4:58pm UTC](https://www.ruby-forum.com/t/nested-form/202972/13 "2011-02-10T16:58:58Z")

</div>

On 10 February 2011 14:57, Colin L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > where one of the id’s is missing.
> > 
> > Hope this isnt too annoying.
> 
> Just paste the error and stack trace here.

I can’t reply to your next message as it is so huge it is hanging  
gmail in firefox. I said the error and trace not the whole log file  
or whatever it is you posted. I think there may be some rude messages  
on the way.

In the trace it says the error occurs at line 80 in  
exercises\_controller in update, which does not line up with the code  
you posted, which does not help, but it appears to be in the call to  
update\_attributes in update that is failing. There is something wrong  
with the params you are passing to update\_attributes, I suggest you  
break in there with the debugger, check out the params and work out  
what is wrong. Once in the debugger you can check that the various  
items you are expecting exist in the database and so on.

In fact the best thing would be to add a test to your automated tests  
checking that whatever you are trying to do works, then you will have  
a simple test case that exhibits the problem. Or perhaps that is how  
you are seeing the error anyway.

Colin

---

<div class="post-metadata">

**Author:** ![seb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8edcca/32.png) [@seb](https://www.ruby-forum.com/u/seb)\
**Post date:** [February 10, 2011, 5:34pm UTC](https://www.ruby-forum.com/t/nested-form/202972/14 "2011-02-10T17:34:18Z")

</div>

On Thu, Feb 10, 2011 at 4:57 PM, Colin L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > > If you add a new exercise with targets you will see the same error  
> > > where one of the id’s is missing.
> > > 
> > > Hope this isnt too annoying.
> > 
> > Just paste the error and stack trace here.
> 
> I can’t reply to your next message as it is so huge it is hanging  
> gmail in firefox. I said the error and trace not the whole log file  
> or whatever it is you posted. I think there may be some rude messages  
> on the way.

I just pasted most of the text from the rails error page.

> In the trace it says the error occurs at line 80 in  
> exercises\_controller in update, which does not line up with the code  
> you posted, which does not help, but it appears to be in the call to  
> update\_attributes in update that is failing. There is something wrong  
> with the params you are passing to update\_attributes, I suggest you  
> break in there with the debugger, check out the params and work out  
> what is wrong. Once in the debugger you can check that the various  
> items you are expecting exist in the database and so on.

Ill try to narrow it down with a debgger. You did get me furthere then  
I was to start with. Thanks for your time it’s much appreciated.

best regards,  
Seb
