I use check_box_tag to get selected beacon, and i to use collection_select to define a value. when user press the button, I want to all selected beacons change value into what collection_select choose, but I don't know how to use ids[] to set my condition like "where...in ..."
here is my action, I want params[:ids] change in to just like [1,2,3]
#beacons = Beacon.where(:id => params[:ids]).update_all(:installer_id => params[:account][:installer_id])
here is my table:
<table class="col-md-12 table-bordered table-striped table-condensed cf">
<thead class="cf">
<th>Check</th>
<th>BeaconUUID</th>
<th>BeaconCategory</th>
<th>BeaconLocate</th>
<th>BeaconName</th>
<th>BeaconAddress</th>
<th>Assign</th>
</thead>
<tbody>
<% #beacons.each do |beacon| %>
<tr>
<td><%= check_box_tag "ids[]", beacon.id %></td>
<td><%= beacon.beacon_uuid %></td>
<td><%= beacon.cid %></td>
<td><%= beacon.lid %></td>
<td><%= beacon.beacon_name %></td>
<td><%= beacon.beacon_address %></td>
<% if beacon.installer_id.nil? %>
<td>not assign</td>
<% else %>
<td>assigned:<%= beacon.installer_id %></td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
<%= form_tag assigned_beacons_path, :method => 'post' do %>
<td><%= collection_select(:account, :installer_id, Account.where('manager_id = ?',session[:user_id]), :id, :email, {:prompt => 'choose!'}, :style => "width: 100px;") %></td>
<td><p data-placement="top" data-toggle="tooltip" title="Edit"><%= submit_tag 'assign', class: "btn btn-info btn-xs"%></p></td>
<% end %>
As was pointed out in comments, check_box_tag should be moved inside of form_tag block:
<%= form_tag assigned_beacons_path, :method => 'post' do %>
<table class="col-md-12 table-bordered table-striped table-condensed cf">
<thead class="cf">
<th>Check</th>
<th>BeaconUUID</th>
<th>BeaconCategory</th>
<th>BeaconLocate</th>
<th>BeaconName</th>
<th>BeaconAddress</th>
<th>Assign</th>
</thead>
<tbody>
<% #beacons.each do |beacon| %>
<tr>
<td><%= check_box_tag "ids[]", beacon.id %></td>
<td><%= beacon.beacon_uuid %></td>
<td><%= beacon.cid %></td>
<td><%= beacon.lid %></td>
<td><%= beacon.beacon_name %></td>
<td><%= beacon.beacon_address %></td>
<% if beacon.installer_id.nil? %>
<td>not assign</td>
<% else %>
<td>assigned:<%= beacon.installer_id %></td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
<td><%= collection_select(:account, :installer_id, Account.where('manager_id = ?',session[:user_id]), :id, :email, {:prompt => 'choose!'}, :style => "width: 100px;") %></td>
<td><p data-placement="top" data-toggle="tooltip" title="Edit"><%= submit_tag 'assign', class: "btn btn-info btn-xs"%></p></td>
<% end %>
Also, dangling <td> blocks don't look good, you should move them into this or another <table> as well.
Related
I am trying to replace the table tag in my html code with p tags denoting that "Result not found!" after searching but I am unsure how.
Controller
def index
if params[:search]
#parameter = params[:search]
#students = Student.all.where("name LIKE :search",search: #parameter)
if #students.blank?
redirect_to students_path
end
else
#students = Student.all
end
end
HTML
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<h1>Listing students</h1>
</div>
<div id="body" class="col-md-12">
<%= form_tag students_path, :method => 'get' do%>
<p>
<%= text_field_tag :search,params[:search]%>
<%= submit_tag "Search"%>
</p>
<%end%>
<%= link_to 'New student', new_student_path %>
<table class="table">
<tr>
<th>Name</th>
<th>ID</th>
<th>Course</th>
<th></th>
</tr>
<% #students.each do |student| %>
<tr>
<td><%= student.name %></td>
<td><%= student.student_id %></td>
<td><%= student.course %></td>
<td><%= link_to 'Show', student_path(student) %></td>
<td><%= link_to 'Edit', edit_student_path(student) %></td>
<td><%= link_to 'Destroy', student_path(student), method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</table>
</div>
</div>
</div>
For now, I redirect to the index page as a stand-in. Any advice?
You can solve the problem in html
<% if #students.present? %>
<table class="table">
<tr>
<th>Name</th>
<th>ID</th>
<th>Course</th>
<th></th>
</tr>
<% #students.each do |student| %>
<tr>
<td><%= student.name %></td>
<td><%= student.student_id %></td>
<td><%= student.course %></td>
<td><%= link_to 'Show', student_path(student) %></td>
<td><%= link_to 'Edit', edit_student_path(student) %></td>
<td><%= link_to 'Destroy', student_path(student), method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</table>
<% else %>
<p>Result not found!</p>
<% end %>
I am want to add data table scroll Y feature its working fine but there is a problem of screen resolution . the screen leave more space from the bellow and it leave space from Y axis like bellow images .
my code-
html.erb
<table class="table table-striped table-hover" id="pendingpodatesort" >
<thead>
<tr>
<th><%= check_box_tag "selectAll", "selectAll" %></th>
<th>Item</th>
<th>Make/Catno</th>
<th>UOM</th>
<th>Qty</th>
<th>Qt_P</th>
<th>Vendor</th>
<th>Phone</th>
<th>No.</th>
<th>Date.</th>
<th>Sort Date</th>
<th>Dlv.Dt</th>
<th>Sort Date</th>
<th>Status</th>
<th>Status Dt</th>
<th>Remarks</th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<% #poitems.each do |poitem| %>
<tr>
<% if current_personnel.designation == 4 || current_personnel.designation == 5 %>
<td></td>
<% else %>
<td><%= check_box_tag 'poitem[]' , poitem.id %></td>
<% end %>
<td><%= poitem.item.description %></td>
<% if poitem.make_id != nil %>
<td><%= (poitem.make.brand.name)+"/"+(poitem.make.catno) %></td>
<%else %>
<td></td>
<% end%>
<% if poitem.uom_type == nil %>
<td><%= poitem.item.uom.shortform %></td>
<% else %>
<td><%= Uom.find_by_id((Item.find_by_id(poitem.item_id)).dual_uom_id).shortform %></td>
<% end %>
<td><%= poitem.quantity %></td>
<% if poitem.pending_quantity != nil %>
<td><%= poitem.pending_quantity %></td>
<%else%>
<td><%= poitem.quantity %></td>
<%end%>
<td><%= poitem.purchaseorder.vendor.description.titlecase %></td>
<td><%= poitem.purchaseorder.vendor.ref_ph %></td>
<td>PO/<%= poitem.indent.parentindent.warehouse.shortform + "/"+(poitem.purchaseorder.serial.to_s) %></td>
<% #podate=poitem.purchaseorder.date %>
<td><%= #podate.strftime("%d/%m") %></td>
<td><%= #podate.strftime("%m/%d/%y") %></td>
<% #delivery_days=poitem.purchaseorder.delivery_days %>
<% if #delivery_days != nil %>
<td><%= (#podate+(#delivery_days.days)).strftime("%d/%m") %></td>
<td><%= (#podate+(#delivery_days.days)).strftime("%m/%d/%y") %></td>
<% else %>
<td></td>
<td></td>
<% end %>
<% if poitem.purchaseorder.awaiting_pi_payment==true %>
<td>Awaiting for PI Payment</td>
<td></td>
<% elsif poitem.dispatched==true %>
<td>Despatched</td>
<% if poitem.dispatched_date != nil %>
<td><%= poitem.dispatched_date.strftime("%d/%m") %></td>
<% else %>
<td></td>
<% end %>
<% elsif poitem.received_by_transporter==true %>
<td>Received at Transporter Godown</td>
<% if poitem.received_by_transporter_on != nil %>
<td><%= poitem.received_by_transporter_on.strftime("%d/%m") %></td>
<% else %>
<td></td>
<% end %>
<% elsif poitem.delivered_at_plant==true %>
<td>Delivered at Plant</td>
<% if poitem.delivered_at_plant_on != nil %>
<td><%= poitem.delivered_at_plant_on.strftime("%d/%m") %></td>
<% else %>
<td></td>
<% end %>
<% else %>
<td></td>
<td></td>
<% end %>
<% if poitem.dispatch_details==nil %>
<td><%= (poitem.followup_remarks) %></td>
<% elsif poitem.followup_remarks==nil %>
<td><%= (poitem.dispatch_details)%></td>
<% else %>
<td><%= (poitem.dispatch_details)+', '+ (poitem.followup_remarks) %></td>
<% end %>
<% if PoAttachment.where(po_id: poitem.po_id)[0]== nil %>
<td></td>
<% else %>
<td><% PoAttachment.where(po_id: poitem.po_id).each do |attachment| %>
<%= link_to attachment.document.url, class: "btn btn-default btn-xs" do %>
<i class="glyphicon glyphicon-paperclip"></i><% end %>
<% end %></td>
<% end %>
<td> <%= link_to controller: "purchase_order_items", action: "change_status", id: poitem.id, class: "btn btn-default btn-xs" do%>
<i class="glyphicon glyphicon-pencil"></i>
<% end %></td>
<td><%= submit_tag ">", name: poitem.id, :class => 'btn btn-default btn-xs' %></td>
</tr>
<% end %>
</tbody>
</table>
application.js
$(document).ready(function(){
var filterTable=$("#pendingpodatesort").DataTable({
"dom": '<"wrapper"ilt>',
"scrollY": '510px',
"scrollX": true,
"lengthMenu": [ [-1, 10, 25, 50, 100], ["All", 10, 25, 50, 100] ],
"aoColumns": [
{"bSortable": true},
{"bSortable": true},
{"bSortable": true},
{"bSortable": true},
{"bSortable": true},
{"bSortable": true},
{"bSortable": true},
{"bSortable": true},
{"bSortable": true},
{"iDataSort": 10},
{"bVisible": false},
{"iDataSort": 12},
{"bVisible": false},
{"bSortable": true},
{"bSortable": true},
{"bSortable": true},
{"bSortable": true},
{"bSortable": true},
{"bSortable": true}
],
"order": [[ 10, "desc" ]]
});
$("#filterbox").keyup(function() {
filterTable.search(this.value).draw();
});
});
How can i adjust this size with out increase zoom on any screen?is there any option to give scroll Y value in %?
Add
scrollCollapse: true
Reference: https://datatables.net/reference/option/scrollCollapse
I have Pieces model, which is store item's parts. When I need, I'm asking to users, check pieces is ok or nok with generated forms.
I am creating reports model to store the forms which I asked from users.
So, when I generate the forms check_box and and text_field works fine. But when I submit the form, I can't get check_box values as a parameter.
{"utf8"=>"✓",
"_method"=>"patch",
"authenticity_token"=>"5OmdXCDixwxru2yBtB3YmT3YF/ZqOByoAJ3J29TyJikxJdA+RXAvGjwu8MBIPlJCROFx4V7AUcA7IIqIgthD9g==",
"notes"=>{"79"=>"asdasda","84"=>""},
"commit"=>"Submit",
"id"=>"5"}
here is my edit.html.erb
<%- model_class = Report -%>
<div class="page-header">
<h1><%=t '.title', :default => [:'helpers.titles.edit', 'Edit %{model}'], :model => model_class.model_name.human.titleize %></h1>
</div>
<% if #report.errors.any? %>
<div id="error_expl" class="panel panel-danger">
<div class="panel-heading">
<h3 class="panel-title"><%= pluralize(#report.errors.count, "error") %> prohibited this report from being saved:</h3>
</div>
<div class="panel-body">
<ul>
<% #report.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
</div>
<% end %>
<table class="table table-striped">
<thead>
<tr>
<th><%= model_class.human_attribute_name(:status) %></th>
<th><%= model_class.human_attribute_name(:serial_no) %></th>
<th><%= model_class.human_attribute_name(:category) %></th>
<th><%= model_class.human_attribute_name(:name) %></th>
<th><%= model_class.human_attribute_name(:brand) %></th>
<th><%= model_class.human_attribute_name(:model) %></th>
<th><%= model_class.human_attribute_name(:quantity) %></th>
</tr>
</thead>
<tbody>
<%= form_tag(report_path(#report), :method => :patch) do %>
<% #pieces.each do |piece| %>
<tr>
<td><div class="form-group">
<%= check_box_tag(:status, name: "status["+piece.id.to_s+"]", class: 'form-control') %>
</div></td>
<td><%= piece.try(:serial_no) %></td>
<td><%= piece.item.category.name %></td>
<td><%= piece.item.name %></td>
<td><%= piece.item.brand %></td>
<td><%= piece.item.model %></td>
<% if piece.serial_no.start_with?("D") %>
<td><%= piece.item.pieces.count %> <%= piece.item.unit.name %></td>
<% else %>
<td><%= piece.item.pieces.sum(:quantity) %> <%= piece.item.unit.name %></td>
<% end %>
</tr>
<tr>
<td colspan=7 class="hidden" id="hebele">
<%= text_field_tag(:note,"", placeholder: "Note ", name: "notes["+piece.id.to_s+"]",class: "form-control ") %>
</td>
</tr>
<% end %>
</tbody>
</table>
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<%= submit_tag("Submit",:class => 'btn btn-primary') %>
<%= link_to t('.cancel', :default => t("helpers.links.cancel")), reports_path, :class => 'btn btn-default' %>
</div>
</div>
<% end %>
<script type="text/javascript">
$("[id='status']").bootstrapSwitch({
size: 'mini',
onColor: 'success',
offColor: 'danger',
indeterminate: true,
onSwitchChange: function(event, state) {
if (state == false){
$("#hebele").removeClass('hidden');
}else if(state == true){
$("#hebele").addClass('hidden');
}
}
});
</script>
controller:
def edit
#pieces = #report.pieces.joins(:item).group(:item_id)
#report = Report.find(params[:id])
end
You need to define the value of the check_box_tag:
<%= check_box_tag :status, piece.id, class: 'form-control' %>
If you're editing a #report, you'll be best using form_for:
<table>
<tbody>
<%= form_for #report do |f| %>
<% #pieces.each do |piece| %>
<tr>
<td>
<div class="form-group">
<%= f.check_box :status, class: 'form-control', price.id %>
</div>
</td>
<td><%= piece.try(:serial_no) %></td>
<td><%= piece.item.category.name %></td>
<td><%= piece.item.name %></td>
<td><%= piece.item.brand %></td>
<td><%= piece.item.model %></td>
<% if piece.serial_no.start_with?("D") %>
<td><%= piece.item.pieces.count %> <%= piece.item.unit.name %></td>
<% else %>
<td><%= piece.item.pieces.sum(:quantity) %> <%= piece.item.unit.name %></td>
<% end %>
</tr>
<tr>
<td colspan=7 class="hidden" id="hebele">
<%= f.text_field :note, placeholder: "Note", class: "form-control" %>
</td>
</tr>
<% end %>
<tr><td colspan="7"><%= f.submit, class: "btn btn-primary" %></td></tr>
<% end %>
</tbody>
</table>
I am not sure what is happening here. When I wrap the form around the table the table disappears. When I remove the form, the table reappears. Thanks in advance. Here is the code:
<% form_tag deposit_checks_path :method => :put do %>
<table>
<thead>
<tr>
<th>Checkbox</th>
<th>Date</th>
<th>Mailer ID</th>
<th>Payment amt</th>
<th>Transaction type</th>
<th>Transaction</th>
<th>Deposit</th>
<th>User</th>
<th colspan="3"></th>
</tr>
</thead>
<tbody>
<% #payments.each do |payment| %>
<tr>
<td><%= check_box_tag "payment_id[]", payment.id, checked = false %></td>
<td><%= payment.created_at %></td>
<td><%= payment.mailer_id %></td>
<td><%= number_to_currency(payment.payment_amt) %></td>
<td><%= payment.transaction_type %></td>
<td><%= payment.transaction_id %></td>
<td><%= payment.deposit_id %></td>
<td><%= payment.user_id %></td>
<td><%= link_to 'Show', payment %></td>
<td><%= link_to 'Edit', edit_payment_path(payment) %></td>
<td><%= link_to 'Destroy', payment, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
<%= submit_tag "Edit Checked" %>
<% end %>
thanks for the help
did you notice in your code?
<% form_tag deposit_checks_path :method => :put do %>
you forgot to add a comma. It should have been
<% form_tag deposit_checks_path, :method => :put do %>
otherwise the method: :put is appended to the action attribute
Main Point:
You forgot to put an equals sign before form_tag
Try this
<%= form_tag deposit_checks_path, :method => :put do %>
Try like this
<table>
<thead>
<tr>
<th>Checkbox</th>
<th>Date</th>
<th>Mailer ID</th>
..
..
</tr>
</thead>
<tbody>
<tr>
<td>
<% form_tag deposit_checks_path :method => :put do %>
<table>
<% #payments.each do |payment| %>
<tr>
<td><%= check_box_tag "payment_id[]", payment.id, checked = false %></td>
<td><%= payment.created_at %></td>
<td><%= payment.mailer_id %></td>
...
...
</tr>
<%end%>
</table>
<% end %>
</td>
</tr>
</tbody>
</table>
This is the controller I have writter for Orders.
def index
if current_user.has_role? :admin
#orders = Order.all.paginate(:page => params[:page], :per_page => 5)
elsif current_user.has_role? :customer
#orders = Order.where(:email => current_user.email).paginate(:page => params[:page], :per_page => 5)
elsif current_user.has_role? :white_label
#orders = Order.where(:performer_id => (Performer.where(:white_label_id => current_user.white_label.id))).paginate(:page => params[:page], :per_page => 5)
else
#orders = current_user.performer.orders.paginate(:page => params[:page], :per_page => 5)
end
#custom_video = CustomVideo.new
end
As you see I have used will_paginate gem to do pagination. This is the view page where I am doing pagination.
<div class="container">
<div class="span 8">
<% if current_user.has_role? :admin %>
<%role =1%>
<%elsif current_user.has_role? :performer %>
<%role =2%>
<% else %>
<%role =3%>
<% end %>
<h3>Awaiting Upload</h3>
<table id="order_table" class="table table-hover">
<thead>
<tr>
<th>id</th>
<th>Location</th>
<th>Performer</th>
<th>Duration</th>
<th>Quality</th>
<th>Delivery</th>
<th>Category</th>
<th>Description</th>
<th>Total</th>
<% if role==2 %>
<th>Select a video to upload for the order</th>
<%end %>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<% #orders.each do |order| %>
<% if order.delivery_time_id=1%>
<% var1=14 %>
<% else %>
<% var1=7 %>
<% end %>
<% if !CustomVideo.find_by_order_id(order.id) and Time.now <= order.created_at.to_date + var1.days%>
<tr>
<td> <%= order.id%></td>
<td><% if order.location %>
<%= order.location.name %>
<% end %></td>
<td><% if order.performer %>
<%= order.performer.first_name %>
<% end %></td>
<td><% if order.duration %>
<%= order.duration.time %>
<% end %></td>
<td><% if order.quality %>
<%= order.quality.name %>
<% end %></td>
<td><% if order.delivery_time %>
<%= order.delivery_time.duration %>
<% end %></td>
<td><% if order.clip_category %>
<%= order.clip_category.name %>
<% end %></td>
<td><% if order.description %>
<%= order.description %>
<% end %></td>
<td><%= order.total %></td>
<% if role==2 %>
<td>
<%= simple_form_for(#custom_video, :html => { :multipart => true, :id => "fileupload" }) do |f| %>
<%= f.error_notification %>
<%= f.file_field :path%><br/><br>
<%= f.hidden_field :order_id,:value => order.id %>
<%=f.button :submit, :value=>"Save", :class=>"btn btn-success" %>
<% end %>
<script id="template-upload" type="text/x-tmpl">
<div class="upload">
{%=o.name%}
<div class="progress"><div class="bar" style="width: 0%"></div></div>
</div>
</script>
<%end%>
</td>
<td>
<% if role==1 %>
<%=form_tag({controller: "orders", action: "refund"}, method: "post") do%>
<%= hidden_field_tag(:id, order.id) %>
<%= submit_tag ("Refund"),:class => "btn btn-success download" %>
<% end %>
<% end %>
</td>
<% if can? :show, #order %>
<td><%= link_to 'Show', order %></td>
<% end %>
<% if can? :update, #order %>
<td><%= link_to 'Edit', edit_order_path(order) %></td>
<% end %>
<% if can? :destroy, #order %>
<td><%= link_to 'Destroy', order, method: :delete, data: { confirm: 'Are you sure?' } %>
</td>
<%else %>
<% next %>
<%end %>
<% end -%>
<% end %>
<%= will_paginate #orders, :param_name => 'awaiting_orders' %>
</tbody>
</table><br/>
<h3>Completed Orders</h3>
<table class="table table-hover" id="order_table">
<thead>
<tr>
<th>id</th>
<th>Location</th>
<th>Performer</th>
<th>Duration</th>
<th>Quality</th>
<th>Delivery</th>
<th>Category</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<% #orders.each do |order| %>
<% if order.delivery_time_id=1%>
<% var1=14 %>
<% else %>
<% var1=7 %>
<% end %>
<% if CustomVideo.find_by_order_id(order.id) and Time.now <= order.created_at.to_date+var1.days%>
<tr>
<td> <%= order.id%></td>
<td><%= order.location.name %></td>
<td><%= order.performer.first_name %></td>
<td><%= order.duration.time %></td>
<td><%= order.quality.name %></td>
<td><%= order.delivery_time.duration %></td>
<td><%= order.clip_category.name %></td>
<td>
<% if role==1 %>
<%=form_tag({controller: "orders", action: "refund"}, method: "post") do%>
<%= hidden_field_tag(:id, order.id) %>
<%= submit_tag ("Refund"),:class => "btn btn-success download" %>
<% end %>
<% end %>
</td>
<% if can? :show, #order %>
<td><%= link_to 'Show', order %></td>
<% end %>
<% if can? :update, #order %>
<td><%= link_to 'Edit', edit_order_path(order) %></td>
<% end %>
<% if can? :destroy, #order %>
<td><%= link_to 'Destroy', order, method: :delete, data: { confirm: 'Are you sure?' } %></td>
<%else %>
<% next %>
<%end %>
<% end -%>
</tr>
<% end %>
<%= will_paginate #orders %>
</tbody>
</table><br/>
<h3>Expired Orders</h3>
<table class="table table-hover" id="order_table">
<thead>
<tr>
<th> id</th>
<th>Location</th>
<th>Performer</th>
<th>Duration</th>
<th>Quality</th>
<th>Delivery</th>
<th>Category</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<% #orders.each do |order| %>
<% if order.delivery_time_id=1%>
<% var1=14 %>
<% else %>
<% var1=7 %>
<% end %>
<% if Time.now > order.created_at.to_date+var1.days%>
<tr>
<td> <%= order.id%></td>
<td><%= order.location.name %></td>
<td><%= order.performer.first_name %></td>
<td><%= order.duration.time %></td>
<td><%= order.quality.name %></td>
<td><%= order.delivery_time.duration %></td>
<td><%= order.clip_category.name %></td>
<% if can? :show, #order %>
<td><%= link_to 'Show', order %></td>
<% end %>
<% if can? :update, #order %>
<td><%= link_to 'Edit', edit_order_path(order) %></td>
<% end %>
<% if can? :destroy, #order %>
<td><%= link_to 'Destroy', order, method: :delete, data: { confirm: 'Are you sure?' } %></td>
<%else %>
<% next %>
<%end %>
<% end -%>
</tr>
<% end %>
<%= will_paginate #orders %>
</tbody>
</table>
<br>
<h3>Orders Refunded</h3>
<table class="table table-hover" id="order_table">
<thead>
<tr>
<th> id</th>
<th>Location</th>
<th>Performer</th>
<th>Duration</th>
<th>Quality</th>
<th>Delivery</th>
<th>Category</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<% #orders.each do |order| %>
<% if order.refunded %>
<tr>
<td> <%= order.id%></td>
<td><%= order.location.name %></td>
<td><%= order.performer.first_name %></td>
<td><%= order.duration.time %></td>
<td><%= order.quality.name %></td>
<td><%= order.delivery_time.duration %></td>
<td><%= order.clip_category.name %></td>
<% if can? :show, #order %>
<td><%= link_to 'Show', order %></td>
<% end %>
<% if can? :destroy, #order %>
<td><%= link_to 'Destroy', order, method: :delete, data: { confirm: 'Are you sure?' } %></td>
<%else %>
<% next %>
<%end %>
<% end -%>
</tr>
<% end %>
<%= will_paginate #orders %>
</tbody>
</table>
<br>
</div>
</div>
<%# link_to 'New Order', new_order_path %>
The problem in this is that. If I click the second page for the first table, it is going to the second for the next table too. I have tried giving the :param_name => 'questions_page' suggested here. But the trouble here is that, I am not using different instance variable for the tables but the same one. How do I solve this?>
You've almost answered your own question. You need to be using separate instance variables for each table if you want them to behave separately.