# Nested link\_to\_function with partial

**URL:** <https://www.ruby-forum.com/t/nested-link-to-function-with-partial/171815>\
**Category:** Rails\
**Created:** [July 9, 2009, 5:31pm UTC](https://www.ruby-forum.com/t/nested-link-to-function-with-partial/171815 "2009-07-09T17:31:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![frontzman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/7feea3/32.png) [@frontzman](https://www.ruby-forum.com/u/frontzman)\
**Post date:** [July 9, 2009, 5:31pm UTC](https://www.ruby-forum.com/t/nested-link-to-function-with-partial/171815/1 "2009-07-09T17:31:29Z")

</div>

I have a service\_ticket model that has\_many :activities. Each of those  
activities habtm :employees. My goal is to have a single page for the  
service ticket model where one could add the activites and then specify  
the employees attached. However when trying to do this, the nested  
link\_to\_function for the employees doesn’t seem to escape the partial  
properly. Is there a function floating around in the ruby docs to help  
here?

the helpers…

def add\_activity\_link(name)  
link\_to\_function name do |page|  
page.insert\_html :bottom, :activity\_items, :partial =\> ‘activity’,  
:object =\> Activity.new  
end  
end

def add\_employee\_link  
link\_to\_function ‘Add Employee’ do |page|  
page.insert\_html :bottom,  
“$(this).up(‘tr’).down(‘.crew\_of\_employees’)”, :partial =\> ‘activity’,  
:object =\> Employee.new  
end  
end

the partials…

Employee:

 Employee \<%= text\_field\_tag "service\_ticket[new\_activity\_attributes][employee\_names][]", employee.id\_with\_full\_name, :class =\> "clean standard employee\_name", :onfocus =\> "CrewCompleter.register($(this), $(this).up().down('.suggestions'), { indicator: $(this).up().down('.indicator') });" %\> \<%= image\_tag 'icons/small/throbber.gif' %\>

 \<%= link\_to\_function image\_tag("icons/x-small/delete.png", :border=\>0), "$(this).up('tr').remove();" %\>

Activity:

\<% new\_or\_existing = activity.new\_record? ? ‘new’ : ‘existing’ %\>

\<% prefix = “service\_ticket[#{new\_or\_existing}\_activity\_attributes][]”  
%\>

\<% fields\_for prefix, activity do |f| -%\>

 \<%= f.collection\_select :name, Activity.all, :id, :name, {:prompt =\> "Select an Activity"}, {:class =\> 'clean standard'} %\> \<%= render :partial =\> "employee", :collection =\> activity.employees, :locals =\> {:new\_or\_existing =\> new\_or\_existing} %\> \<%= add\_employee\_link %\>

\<% end -%\>

and finally the error…

Error: missing } after property list  
Source File: [http://localhost:3000/service\_tickets/137/edit#](http://localhost:3000/service_tickets/137/edit#)  
Line: 2, Column: 106  
Source Code:  
').down(\‘.crew\_of\_employees\’), { bottom: \n

Employee\<\\/td\>\\n \\n \<input class=\\"clean standard employee\_name\\" id=\\"service\_ticket\_new\_activity\_attributes\_employee\_names\_\\" name=\\"service\_ticket[new\_activity\_attributes][emplo...

any ideas?

Thanks.

---

<div class="post-metadata">

**Author:** ![frontzman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/7feea3/32.png) [@frontzman](https://www.ruby-forum.com/u/frontzman)\
**Post date:** [August 2, 2009, 3:20pm UTC](https://www.ruby-forum.com/t/nested-link-to-function-with-partial/171815/2 "2009-08-02T15:20:05Z")

</div>

Did you solve this problem? I have an issue that is nearly identical  
in nature to your own. I’d be interested in hearing solutions or  
workarounds if you’ve discovered one.

On Jul 9, 10:31 am, Bryan F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
