2012-03-02 3 views
3

나는 레일즈 초보자입니다. 레일을 사용하여 다운로드 할 사람들을위한 rtf 문서를 생성하는 빠르고 쉬운 방법이 있는지 누군가가 알 수 있습니까? 예를 들어, "views/users/show.html.erb"가 있으면보기가 일반적으로 html로 출력되므로 사람들이 동일한 rtf 문서로 다운로드 할 수있게하려면?레일즈 3.2에서 rtf 문서 생성

+0

이 보석을 발견했습니다. https :// /github.com/thechrisoshow/rtf –

답변

7

ruby-rtf 당신이 찾고있는 보석입니다. here

가 초기화/mime_types.rb이 추가 RTF 세대의 몇 가지 예는 다음과 같습니다

Mime::Type.register "text/richtext", :rtf 

코드가 당신에게 아이디어를 제공하기 위해 :

document = RTF::Document.new(RTF::Font.new(RTF::Font::ROMAN, 'Times New Roman')) 
document.paragraph do |p| 
    p << "This is the first sentence in the paragraph. " 
    p << "This is the second sentence in the paragraph. " 
    p << "And this is the third sentence in the paragraph." 
end 

send_file document, :type=>"text/richtext" 
+1

링크는 https://rubygems.org/gems/ruby-rtf이어야합니다. –

+0

링크가 수정되었습니다. 감사합니다 @AlexGhiculescu – ScottJShea