# Jquery and accepts\_nested\_attributes\_for model creation

**URL:** <https://www.ruby-forum.com/t/jquery-and-accepts-nested-attributes-for-model-creation/161001>\
**Category:** Rails\
**Created:** [February 22, 2009, 12:40am UTC](https://www.ruby-forum.com/t/jquery-and-accepts-nested-attributes-for-model-creation/161001 "2009-02-22T00:40:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yaphi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/e274bd/32.png) [@yaphi](https://www.ruby-forum.com/u/yaphi)\
**Post date:** [February 22, 2009, 12:40am UTC](https://www.ruby-forum.com/t/jquery-and-accepts-nested-attributes-for-model-creation/161001/1 "2009-02-22T00:40:47Z")

</div>

I am getting lost in dynamically creating Asset objects while creating  
a new Project. I am using the new accepts\_nested\_attributes\_for method  
in Rails 2.3 and have this close to working, I just can’t figure out  
what my custom controller method “add\_asset” should be doing here. I  
am using jQuery instead of Prototype.

Here is the relevant code:  
[http://pastie.org/private/oom26fy67vkahsamjpvg](http://pastie.org/private/oom26fy67vkahsamjpvg)

I know that the new asset isn’t getting built, and I need to do that  
in the add\_asset controller action, but I also don’t know how to  
generate a file\_field for that object whenever it’s created.

Right now the file\_field that’s getting generated using nested\_for is:

but my input field from the add\_asset controller method is:

Any help would be appreciated. I’ve been staring at this all day long!

---

<div class="post-metadata">

**Author:** ![yaphi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/e274bd/32.png) [@yaphi](https://www.ruby-forum.com/u/yaphi)\
**Post date:** [April 3, 2009, 1:16am UTC](https://www.ruby-forum.com/t/jquery-and-accepts-nested-attributes-for-model-creation/161001/2 "2009-04-03T01:16:35Z")

</div>

I have the same problem, any idea ?

yaphi wrote:

> Here is the relevant code:  
> [http://pastie.org/private/oom26fy67vkahsamjpvg](http://pastie.org/private/oom26fy67vkahsamjpvg)
> 
> I know that the new asset isn’t getting built, and I need to do that  
> in the add\_asset controller action, but I also don’t know how to  
> generate a file\_field for that object whenever it’s created.  
> …
> 
> Any help would be appreciated. I’ve been staring at this all day long!
