RoR will_paginate没有路由匹配错误

时间:2017-01-11 06:23:01

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

offers_controller.rb文件

def store_locator
  city_name = params[:city]
  @flag = true
  per_page = 5
  if !city_name.blank?
    store = StoreCity.find_by_city(city_name.downcase)
  end
  if !store.nil?
    @storelist= StoreAddress.where(:city_id=>store.id)
    @flag = false
  else 
  @storelist= StoreAddress.order(:store_name).paginate(:page => params[:page], :per_page => per_page)
  end
  respond_to do |format|
    format.html
  end
end

store_locator.html.erb弹出以下错误

  

没有路线匹配{:action =>“store_locator”,:controller =>“spree / offers”,:escape => nil,:page => 2} ** at

<%=will_paginate @storelist ,:params => { :escape => nil }, :class => 'store_paging'%>

代码段:

<div class="col-md-12" id="loadicon"></div>
  <%if @flag%>
    <%=will_paginate @storelist ,:params => { :escape => nil }, :class => 'store_paging'%> 
  <%end%>
<div id="storediv" style="background-color:#efefef;">

routes.rb具有正确的命名空间

get '/store_locator' => 'offers#store_locator'

will_paginate 3.1.5版 RoR版本4.2.3

1 个答案:

答案 0 :(得分:0)

使用命令检查路线:

rake routes

列出所有路由并检查/ store_locator是调用哪个控制器和动作。