轨道上的jquery无页面ruby:模板丢失

时间:2012-10-17 05:36:56

标签: ruby-on-rails ruby

我使用jquery pageless进行无页面滚动。我的文件是游戏控制器

def result
  @game = GameResult.group("game_id").where(@where).order('registered_date desc')
  @results = @game.paginate(:per_page => 3, :page => params[:page])   
  if request.xhr?
    sleep(3) # make request a little bit slower to see loader :-)
    render :partial => @results
  end
end

在application.html.erb

它有div和yield文件包含在div标签中。

在应用程序助手中,

def pageless(total_pages, url=nil, container=nil)
  opts = {
      :totalPages => total_pages,
      :url        => url,
      :loaderMsg  => 'Loading more results',
     # :loaderImage => image_path("load.gif")
    }    
  container && opts[:container] ||= container    
  javascript_tag("$('#results').pageless(#{opts.to_json});")
end

路线

get '/games' =>'games#result'  
get '/games/result' => 'games#result'
rake route in terminal
games GET    /games(.:format)    games#result  

在游戏中查看,我有两个文件 - result.html文件和_result.html文件result.html.erb文件

<%= render(:partial => 'result', :collection => @results) %>
<%= will_paginate(@results) %>
<%= pageless(@results.total_pages,games_path,"#results") %>
<style>#results {overflow:auto;}</style>

_result.html.erb文件

<div style="margin-bottom:3em">
<div><%= result.level %></div>
<div><%= result.game_timing %></div>
</div>

使用此代码,当我向下滚动时,我得到了模板丢失错误。 " Missing partial game_results/game_result with {:locale=>[:en], :formats=>[:html, :text, :js, :css, :ics, :csv, :png, :jpeg, :gif, :bmp, :tiff, :mpeg, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json, :pdf, :zip]" ....此代码有什么问题。

0 个答案:

没有答案