Nested link_to_function with partial

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#
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.

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. [email protected]

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