试图使用Wicked PDF.
我在控制器中有这个代码
def pdf
pdf = WickedPdf.new.pdf_from_string(
render_to_string(
pdf: 'filename.pdf',
template: '/pages/poa.html.slim',
layout: '/layouts/pdf'),
header: {
content: render_to_string({
template: '/pdfs/poa_header.html.slim',
layout: '/layouts/pdf'
})
})
save_path = [Rails.root, '/public/pdf/', 'filename.pdf'].join
File.open(save_path, 'wb') do |file | file << pdf
end
end
Run Code Online (Sandbox Code Playgroud)
我在尝试执行上面的操作时收到此错误消息
RuntimeError (Failed to execute:
Error: "\xFE" from ASCII-8BIT to UTF-8):
Run Code Online (Sandbox Code Playgroud)
我已经尝试清空我正在渲染的模板和布局的内容但仍然出错.
我想执行一些这样的查询:
SELECT
folders.*,
(SELECT
files.filename
FROM
files
WHERE
files.folder_id = folders.id
)
as files
FROM
folders
ORDER BY
files[column name of filename]
Run Code Online (Sandbox Code Playgroud)
子查询可能会给出多于1个结果,因此我想将结果加入到单个列文件名中.
我正在使用Postgres.我添加了Rails作为标记,因为你可能会建议一些可以处理这个问题的Rails魔法.
我在用
Paranoia gem(3.1.1)
Rails 3.2
Run Code Online (Sandbox Code Playgroud)
我注意到has_one :model, dependent: :destroy尚未恢复。
比方说
class User < ActiveRecord::Base
acts_as_paranoid
has_many :posts, dependent: :destroy
has_one :profile, dependent: :destroy
Run Code Online (Sandbox Code Playgroud)
如果我做..
@user.destroy
User.restore(@user.id, recursive: true)
Run Code Online (Sandbox Code Playgroud)
用户及其帖子将被恢复,但个人资料不会被恢复。
我有什么可以做的呢?
顺便说一句,我使用的是偏执狂的分叉版本,因为我无法获得此版本https://github.com/radar/paranoia/blob/rails3/lib/paranoia.rb#L105