开发者

When rendering js.erb file, it renders layout with the javascript, is it a bug?

开发者 https://www.devze.com 2023-01-22 23:24 出处:网络
A workaround that I found was to explicitly state in controller render :action 开发者_运维问答=> :some_action, :layout => false

A workaround that I found was to explicitly state in controller

render :action 开发者_运维问答=> :some_action, :layout => false

otherwise JavaScript fails to work

Anyone found this problem or maybe something is wrong with my configuration...


it's a normal behaviour. How he know that you don't want render this layout ?

You can avoid the layout to all of your js format in add in your ApplicationController

Class ApplicationController

  layout :no_in_js_format

  def no_in_js_format
    if request.format == :js
      return nil
    else
      return 'application
    end
  end
end


Real solution: I had rhtml for layouts and rails was defaulting all templates to that layout. Once I renamed all rhtml to html.erb, it fixed the problem. Here is the article about this in detail: http://yehudakatz.com/2009/06/18/and-the-pending-tests-they-shall-pass/

0

精彩评论

暂无评论...
验证码 换一张
取 消