好的,这是我目前无法解决的交易。

因此,我将执行以下操作:

def get
  @page = Page.find_by_title(params[:title])
  respond_to do |format|
    format.html # get.html.erb
    format.js   # get.js.coffee
  end
end

根据呈现的是AJAX调用还是普通的GET请求,呈现器将呈现get.html.erb或get.js.coffee。

在开发中,即由以下日志条目显示:

Started GET "/pages/medien/get" for 127.0.0.1 at 2011-12-11 18:58:31 +0100
Processing by PagesController#get as JS
Parameters: {"title"=>"medien"}    
Rendered pages/_get.html.erb (153.0ms)
Rendered pages/get.js.coffee (1185.0ms)
Completed 200 OK in 1230ms (Views: 1220.0ms | ActiveRecord: 5.0ms)

在生产中,相同的请求和相同的代码将导致如下日志条目:

Started GET "/pages/medien/get/" for 91.11.86.230 at 2011-12-11 18:57:44 +0100
Processing by PagesController#get as JS
Parameters: {"title"=>"medien"}
Read fragment views/mypage/pages/medien/get (0.1ms)
Rendered pages/_get.html.erb (0.8ms)
Rendered pages/get.html.erb (0.9ms)
Completed 200 OK in 2ms (Views: 1.5ms | ActiveRecord: 0.2ms)

我简直不明白为什么它甚至声明将其作为JavaScript处理,但随后甚至不抛出错误就不执行get.js.coffee中的javascript!

  ask by Rhywden translate from so

本文未有回复,本站智能推荐: