Add a custom format in Rails (that will work with respond_to)

Posted by Horace Loeb on Stack Overflow See other posts from Stack Overflow or by Horace Loeb
Published on 2010-03-16T16:34:10Z Indexed on 2010/03/16 16:41 UTC
Read the original article Hit count: 387

Filed under:
|
|

I have map.resources :posts and I want to be able to serve post bodies in markdown format. So I set up my respond_to block:

respond_to do |format|
  format.markdown {
    render :text => @post.body.to_s
  }
end

But when I try to access /posts/1234.markdown, I get this error:

NameError (uninitialized constant Mime::MARKDOWN):
  app/controllers/posts_controller.rb:96:in `show'
  app/controllers/posts_controller.rb:79:in `show'

How do I add markdown as an acceptable format? Where can I see the list of acceptable formats?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about rest