15
보기를 문자열로 렌더링해야하는 작업이 있습니다. 뷰는 index.xml.erb라고합니다. 나는 render_to_string와이를 달성하기 위해 노력하고 있어요 :형식 지정 : render_to_string에서 "xml"이 무시되었습니다.
my_string = render_to_string(layout: false, format: "xml")
render_to_string 대신 index.html.erb의 내용을 렌더링하고 my_string에 할당된다. 내가 뭘 놓치고 있니?
주 : 나는 같은 것을 할 수 있다는 것을 알고 :
my_string = render_to_string(:action => "#{self.action_name}.xml.erb")
하지만 난 "형식"옵션이 render_to_string으로 명예를하지 않는 이유에 대해 궁금합니다.