收到此错误:
NoMethodError in AwardsController#certificate
undefined method `scan' for #<Array:0x0000000354bd40>
宝石文件:
gem 'pdfkit'
跑捆绑安装
应用程序.rb:
require 'pdfkit'
config.middleware.use "PDFKit::Middleware"
路线.rb:
match 'awards/certificate/:id' => 'awards#certificate', :as => :certificate, :via => :get
奖项控制器:
def certificate
@award = Award.find(params[:id])
html = render :layout => false
kit = PDFKit.new(html, :page_size => 'Letter')
kit.stylesheets << RAILS_ROOT + '/public/stylesheets/scaffold.css'
send_data(kit.to_pdf, :filename => "#{@award.nominee_fullname Certificate}", :type => 'application/pdf')
end
耙中间件:
use PDFKit::Middleware
耙路线:
certificate GET /awards/certificate/:id(.:format) awards#certificate
如果我将 .pdf 放在 URL 的末尾,我会得到:
Routing Error
No route matches [GET] "/highfive/awards/certificate/51"
有人知道我做错了吗?提前致谢。