开发者

Rails New Action not returning HTML on AJAX GET

I'm working on a project where I upgraded the rails gem from 2.3.5 to 2.3.11 now I can't get the controller 开发者_Go百科actions to return HTML via jQuery ajax get. For example when I run this javascript: $(function(){ $.get("/inbox/new"); });

I can see in Firebug that the request was received with a status of 200. I can see the request being rendered in my log. I can see that the CSRF token is being passed in the ajax get (but I don't know why it would matter anyways since it's a get and not a post).

I tried the respond to block respond_to do |format| format.html {render :layout => false, :action => :new} end

The only way I can get the controller action to return anything (once again confirmed via Firebug) is by using render :text => "whatever" in the controller action.

Any ideas?! Is there something different in rails 2.3.11 that I'm missing?!


I figured it out. A very small but significant line of code screwed me up. There was a content_for block in the new.html.haml view. So view rendered on AJAX GET but the content didn't render because there was no layout specified. I can't believe I spent as many hours on this as I did. Humbling experience.

Could I at least get some votes for my many lost hours of productivity?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜