Nested_form

I’m trying to use the nested form gem from

However I’m getting undefined method `muscle_id’ for
#Muscle:0x00000004f6e0b0

My code can be found at https://gist.github.com/818944

best regards,
Seb

On 9 February 2011 20:37, Seb [email protected] 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

On Wed, Feb 9, 2011 at 10:20 PM, Colin L. [email protected]
wrote:

On 9 February 2011 20:37, Seb [email protected] 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?

On 9 February 2011 21:26, Sebastian [email protected]
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

On 9 February 2011 21:46, Sebastian [email protected]
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

On Wed, Feb 9, 2011 at 10:31 PM, Colin L. [email protected]
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.

On 10 February 2011 10:36, Sebastian [email protected]
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

On Thu, Feb 10, 2011 at 10:07 AM, Colin L. [email protected]
wrote:

of code that is causing the problem.
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.

On Thu, Feb 10, 2011 at 11:50 AM, Colin L. [email protected]
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.

[email protected]:~/fitfit$ cat app/views/exercises/_form.haml | gist
https://gist.github.com/820315
[email protected]:~/fitfit$ cat app/controllers/exercises_controller.rb | gist
https://gist.github.com/820317
[email protected]:~/fitfit$ cat app/models/exercise.rb | gist
https://gist.github.com/820318

I hope that the above terminal out speaks for it self :slight_smile:

On 10 February 2011 11:00, Sebastian [email protected]
wrote:

are using the gem in the code you posted.
https://gist.github.com/820318

I hope that the above terminal out speaks for it self :slight_smile:

You have not shown the error and stack trace.

Colin

On 10 February 2011 14:35, Sebastian [email protected]
wrote:

Hope this isnt too annoying.

Just paste the error and stack trace here.

Colin

On Thu, Feb 10, 2011 at 2:30 PM, Colin L. [email protected]
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
[email protected]:~/fitfit$ cat app/models/exercise.rb | gist
https://gist.github.com/820318

I hope that the above terminal out speaks for it self :slight_smile:

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 [email protected] and password ==
“password” at
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.

On 10 February 2011 14:57, Colin L. [email protected] 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

On Thu, Feb 10, 2011 at 4:57 PM, Colin L. [email protected]
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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs