Pretty new to rails. Building a hypothetical little application to show employees' vacation days in a calendar. I'm trying to list those employees with a checklist (to customize output) and I'm getting what appears to be the array, spat back at me once the loop finishes. Can't figure out why - I have no call for direct output. It appears to be spitting out when the loop ends. Any help?
<%= @employees.each do |empl| %>
<label><%= check_box 'employee','id',{:checked => 'checked' },empl.id %>
<%= link_to empl.name, edit_employee_path(empl), :target => '_blank' %></label>
<% end unless @employees.empty? %>
<%= link_to 'Add Employee', new_employee_path %>
And here's the output:
<label><input name="employee[id]" type="hidden" value="0" /><input checked="checked" id="employee_id" name="employee[id]" type="checkbox" value="1" />
<a href="/employees/1/edit" target="_blank">Test 1</a></label>
<label><input name="employee[id]" type="hidden" value="0" /><input checked="checked" id="employee_id" name="employee[id]" type="checkbox" value="2" />
<a href="/employees/2/edit" target="_blank">Test</a></label>
[#<Employee id: 1, name: "Test 1", created_at: "2012-07-06 19:58:03", updated_at: "2012-07-06 19:59:55">, #<Employee id: 2, name: "Test", created_at: "2012-07-06 21:10:10", updated_at: "2012-07-06 21:10:10">]
<a href="/employees/new">Add Employee</a>
Semantically, the unless
after the loop seems out of place but it's my understanding that if I wanted to put it before the loop I'd be adding an extra end
afterwards. Is that related? Any idea what's going on?