0
我已阅读'ruby-rtf'的文档。如何在Rails应用程序中使用ruby-rtf导出RTF文件?
我不清楚如何将这与我的控制器集成。我也做了以下内容:
gem install ruby-rtf
插入到配置/初始化/ mime_types.rb
Mime::Type.register "text/richtext", :rtf
我的观点有路由到以下控制器动作的导出按钮。这里是我的控制文件:
def export_file 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" end
我碰到下面的错误,我究竟做错了什么?
uninitialized constant JobVacanciesController::RTF
你的宝石添加到您的Gemfile?也许它也需要在控制器的最上方有一个'require'RTF''。 – KappaNossi
我已经添加到Gemfile中:gem'ruby-rtf',我向控制器添加了require'RTF',并且出现以下错误:无法加载此文件 - RTF – Venomoustoad