How to override a render to create a custom "render :my_format => argument" in rails 2.3(.5)?
        Posted  
        
            by Rafael
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Rafael
        
        
        
        Published on 2010-04-13T14:24:13Z
        Indexed on 
            2010/04/20
            4:23 UTC
        
        
        Read the original article
        Hit count: 516
        
Hey!
I would like to create a custom render as specified in title.
For instance, I have my controller:
class MyController < ApplicationController
  def index
    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @objs }
    end
  end
end
, but I would like something like this:
class MyController < ApplicationController
  def index
    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @objs }
      format.my_format  { render :my_format => @objs }
    end
  end
end
Is it possible? What are the steps I need to make it work?
Thanks in advance!
UPDATE
I want something like in here. So I replaced the @objs with a method but it didn't work either (the method wasn't called).
Obs: I register the mime type at config/initializers/mime_types.rb.
© Stack Overflow or respective owner