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:

<tr>
  <td>Employee</td>
  <td>
    <%= 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') });" %>
    <span class="indicator" style="display: none;"><%= image_tag
'icons/small/throbber.gif' %></span>
    <div class="suggestions standard"></div>
  </td>
  <td><%= link_to_function image_tag("icons/x-small/delete.png",
:border=>0), "$(this).up('tr').remove();" %></td>
</tr>

Activity:

<% new_or_existing = activity.new_record? ? 'new' : 'existing' %>

<% prefix = "service_ticket[#{new_or_existing}_activity_attributes][]"
%>

<% fields_for prefix, activity do |f| -%>
<tr>

  <td><%= f.collection_select :name, Activity.all, :id, :name, {:prompt
=> "Select an Activity"}, {:class => 'clean standard'} %></td>
  <td class="crew_of_employees">
    <%= render :partial => "employee", :collection =>
activity.employees, :locals => {:new_or_existing => new_or_existing} %>
  </td>

<td><%= add_employee_link %></td>
</tr>

<% 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: <tr>\\n
<td>Employee<\\/td>\\n  <td>\\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.
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to