how can I generate json from respond_to method in rails?

Posted by Oberon Dude on Stack Overflow See other posts from Stack Overflow or by Oberon Dude
Published on 2010-04-02T13:04:35Z Indexed on 2010/04/02 13:23 UTC
Read the original article Hit count: 229

Filed under:
|
|

If I have a block of code like this:

  def show
@post = Post.find(params[:id])

respond_to do |format|
  format.html # show.html.erb
  format.xml  { render :xml => @post }
end

end

How do I add something like

format.json

Any tips, pointers, ideas gladly welcomed...

© Stack Overflow or respective owner

Related posts about JSON

Related posts about respond-to