27 May 2010

render :js in Rails 3

I just wasted a ton of time trying to get render :js working. I hope this saves a google visitor time or someone tells me what I was doing wrong. 

According to guides.rubyonrails.org, render :js should work, but I kept getting an error about nil formats. Some people used render :text, but even after setting :content_type to "text/javascript", it would just display the text. So I finally gave up and used the javascript_tag. This was all done in a helper. I also just wanted to post something using Markdown to Posterous.

UPDATE: Markdown didn't work, so I'm using a gist.