How do I render a partial of a different format in Rails?

How do I render a partial of a different format in Rails?

Asked on January 12, 2019 in Ruby on Rails.
Add Comment


  • 2 Answer(s)

    Rails 3.2.3 calling render :partial,

    :formats => [:html]
    

    or,

    :format => 'html'
    

    Answered on January 12, 2019.
    Add Comment

    Rails 3 using  with_format block work in small different:

    def with_format(format, &block)
      old_formats = formats
      self.formats = [format]
      block.call
      self.formats = old_formats
      nil
    end
    

    Answered on January 12, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.