Will_paginate点击页面链接不显示任何内容

时间:2015-09-25 09:26:25

标签: javascript ruby-on-rails ruby will-paginate

当我点击分页链接时,我的标签内容只显示空白页面。我不懂为什么。请帮帮我。我第一次加载页面时会加载我的图像,但是当我在分页按钮上单击第2页时没有任何内容出现。

我的观看代码

<script type="text/javascript">
    $(document).ready(function(){
        $('a[data-toggle="tab"]').on('show.bs.tab', function(e) {
            localStorage.setItem('activeTab', $(e.target).attr('href'));
        });
        var activeTab = localStorage.getItem('activeTab');
        if(activeTab){
            $('#TabLength a[href="' + activeTab + '"]').tab('show');
        }
    });
</script>
<div>
<div id="TabBlock">
<ul class="nav nav-tabs" id="TabLength">
    <% @biscuit.each_index do |i| %>
      <% if i == 0 %>
        <li class="active"><a data-toggle="tab" href="#<%= @biscuit[i] %>"><%= @biscuit[i] %></a></li>
      <% else %>
        <li><a data-toggle="tab" href="#<%= @biscuit[i] %>"><%= @biscuit[i] %></a></li>
      <% end %>
    <% end %>
</ul>
<div class="tab-content">
  <%= render "products" %>
</div>
</div>
</div>

我的部分产品代码

<% @biscuit.each_index do |i| %>
    <% if i == 0 %>
      <div class="tab-pane fade in active" id="<%= @biscuit[i] %>">
        <div class="row" id="PictureSetting">
        <% @title = @biscuit[i].camelize.constantize %>
        <% @testpage = @title.paginate(:page => params[@biscuit[i]], :per_page => 9) %>
            <% @testpage.each do |i| %>
              <div class="col-md-4" id="ProductPic">
                <%= image_tag(i.name , class:"img-thumbnail", size:"180x180") %>
              </div>
          <% end %>
        </div>
        <%= will_paginate @testpage, :param_name => @biscuit[i] %>
      </div>
    <% else %>
      <div class="tab-pane fade" id="<%= @biscuit[i] %>">
        <div class="row" id="PictureSetting">
        <% @title = @biscuit[i].camelize.constantize %>
        <% @testpage = @title.paginate(:page => params[@biscuit[i]], :per_page => 9) %>
           <% @testpage.each do |i| %>
              <div class="col-md-4" id="ProductPic">
                <h1>Hello</h1>
              </div>
          <% end %>
        </div>  
        <%= will_paginate @testpage, :param_name => @biscuit[i] %>
        </div>  
      </div>
    <% end %>
<% end %>

我的控制器代码

class UsersController < ApplicationController

BiscuitCategory = Array.new

def show
  @user = User.find(params[:id])

end

def new
end 

def edit
  @user = User.find(params[:id])
end

def cashier
  @user = User.find(params[:id])
  @biscuit = category_store
end

def category_store
  BiscuitCategory.clear
  totalnum = Biscuit.count("BiscuitType")
  counter = 1
  while counter <= totalnum
    BiscuitCategory.push(Biscuit.find(counter).BiscuitType)
    counter+=1
  end 
  return BiscuitCategory
end 

我的路线代码

Rails.application.routes.draw do

  # The priority is based upon order of creation: first created -> highest priority.
  # See how all your routes lay out with "rake routes".

  # You can have the root of your site routed with "root"
  root 'webpage#login'
  get 'login' => 'webpage#login'
  post 'login' => 'webpage#create'
  delete 'logout' => 'webpage#destroy'
  resources :users do
    member do
      get 'cashier'
    end
  end

0 个答案:

没有答案