Thursday, 15 August 2013

Error while deleting multiple records in database ROR

Error while deleting multiple records in database ROR

The following is the code in which i want to delete multiple records but
getting error... my view named um_org_data in which the code from the html
file name is index.html.erb
<%= form_tag destroy_um_org_data_path, method: :delete, data: { confirm:
'Are you sure you want to delete all these?' } do %>
<table class="table table-hover table-condensed">
<tr>
<th></th>
<th>Organization Name</th>
<th>Organization Description</th>
<th>Office Address</th>
<th>Office Phone Number</th>
<th>Actions</th>
</tr>
<% @um_org_data.each do |um_org_data| %>
<tr>
<td><%= check_box_tag "deleted_ids[]", um_org_data.id %></td>
<td><%= um_org_data.org_name %></td>
<td><%= um_org_data.org_description%></td>
<td><%= um_org_data.offc_addr%></td>
<td><%= um_org_data.offc_ph%></td>
<td>
<%= link_to "<i class='icon-eye-open'></i>".html_safe,
um_org_data,"data-original-title" => "View Details",
"data-placement" => "bottom", :rel => "nofollow", :class
=> 'bg-color-none' %>
<%= link_to "<i class= 'icon-edit'></i>".html_safe,
edit_um_org_datum_path(um_org_data), "data-original-title"
=> "Edit", "data-placement" => "bottom", :rel =>
"nofollow", :class => 'bg-color-none'%>
<%= link_to "<i class= 'icon-trash'></i>".html_safe,
um_org_data, method: :delete, data: { confirm: 'Are you
sure?' }, "data-original-title" => "Delete",
"data-placement" => "bottom", :rel => "nofollow", :class
=> 'bg-color-none' %>
</td>
</tr>
<%end%>
</table>
<%= button_tag(type: "submit", class: "btn") do %>
Delete Selected <i class="icon-trash"></i>
<% end %>
<% end %>
and for this my controller name um_org_data_controller.rb has the
following method against this action.
def destroy
@um_org_datum = UmOrgDatum.find(params[:id])
@um_org_datum.destroy
respond_to do |format|
format.html { redirect_to um_org_data_url }
format.json { head :no_content }
end
end
i am facing error in the very first line of the view name index.html.erb
the following is the detail of error that i found.
NameError in Um_org_data#index
undefined local variable or method `destroy_um_org_data_path' for
#<#<Class:0x00000004582a10>:0x007fa9e42f4e38>
<%= form_tag destroy_um_org_data_path, method: :delete, data: { confirm:
'Are you sure you want to delete all these?' } do %>
<table class="table table-hover table-condensed">
<tr>
<th></th>
where as delete below in the view code is working fine...... Thanks in
Advance.

No comments:

Post a Comment