Parent - Childen - Grandchildren: If children isn't saved, all but one grandchildren are not saved.

1 view
Skip to first unread message

harry

unread,
Apr 24, 2008, 4:54:47 PM4/24/08
to attribute_fu
I have a setup much like the one pimpmaster described. It more or less
works as expected.

Story has_many :sections
Section has_many :routes

But, if I edit a story and then add a new section and add three routes
to that new, unsaved section, they all have this ID:

story[section_attributes][new][-1][route_attributes][new][-1][name]

And because of that only one of them is actually passed on and saved.

If I save my section first, they will get fine numbering, -1, -2, -3.

Any ideas?

harry

unread,
May 1, 2008, 11:19:56 AM5/1/08
to attribute_fu
Here is the pastie with source code and the likes.

http://pastie.org/189909

harry

unread,
May 8, 2008, 11:57:24 AM5/8/08
to attribute_fu
No one? It's pretty important.

James Golick

unread,
May 8, 2008, 12:32:15 PM5/8/08
to attrib...@googlegroups.com
Sorry I haven't responded yet, been busy...

I can't seem to repeat the bug here, either. There is a javascript variable that counts the number of new forms added. Obviously, it's not being incremented.

Could you pastie the generated HTML pls?

harry

unread,
May 8, 2008, 12:44:42 PM5/8/08
to attrib...@googlegroups.com
Generated HTML at http://pastie.org/193724

2008/5/8 James Golick <james...@gmail.com>:

James Golick

unread,
May 8, 2008, 12:57:30 PM5/8/08
to attrib...@googlegroups.com
can you try alert'ing attribute_fu_sound_count in firebug before and after adding a few extra forms.

This is odd..

harry

unread,
May 8, 2008, 1:01:07 PM5/8/08
to attrib...@googlegroups.com
Not defined before adding anything, but after that, it is actually
updated, and contains -1, -2, -3 etc..

2008/5/8 James Golick <james...@gmail.com>:

harry

unread,
May 8, 2008, 3:08:16 PM5/8/08
to attrib...@googlegroups.com
the add link:
"name=\"story[play_attributes][new][-1][sound_attributes][new][-1][name]\"

-1 should be #{number} so .evaluate substitutes it with
attribute_fu_sound_count.

That's rather weird.

2008/5/8 harry <ichve...@gmail.com>:

harry

unread,
May 14, 2008, 11:31:49 AM5/14/08
to attrib...@googlegroups.com
2008/5/8 James Golick <james...@gmail.com>:

> I can't seem to repeat the bug here, either.

This is beginning to freak me out. So, I created a new rails-project
with only bare functionality, but still perfectly reproducing the
issue.

It's on GitHub: http://github.com/ichverstehe/af_grandchildren_issue/tree/master

Please, feel free to take a look at it.

James Golick

unread,
May 14, 2008, 11:39:13 AM5/14/08
to attrib...@googlegroups.com
great! that's exactly what I need to diagnose the issue. I'll check it out this week for sure.

Thanks,

j

harry

unread,
Jun 17, 2008, 4:25:27 PM6/17/08
to attribute_fu
Some minor stuff missing at GitHub before, like the actual plugin :)

New commits: http://github.com/ichverstehe/af_grandchildren_issue/tree/master

Rails version: 2.1.0

On 14 Maj, 17:39, "James Golick" <jamesgol...@gmail.com> wrote:
> great! that's exactly what I need to diagnose the issue. I'll check it out
> this week for sure.
> Thanks,
>
> j
>
> On Wed, May 14, 2008 at 11:31 AM, harry <ichverst...@gmail.com> wrote:
>
> > 2008/5/8 James Golick <jamesgol...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages