我在Heroku上运行一个网站,并且在加载谷歌字体时遇到了一些麻烦.
我的typography.sass文件包含:
@import url(http://fonts.googleapis.com/css?family=Bitter)
h1
font-family: 'Bitter', Helvetica, serif
Run Code Online (Sandbox Code Playgroud)
我的production.rb文件包含以下行:
config.serve_static_assets = true
config.assets.compile = true
config.assets.digest = true
Run Code Online (Sandbox Code Playgroud)
我的Gemfile包括:
gem 'rails_12factor', group: :production
Run Code Online (Sandbox Code Playgroud)
我已经完成了资产管道的所有Heroku问题,并且我已经将所有图像和css文件正确地加载到生产中,但无论出于何种原因,该字体仅适用于开发.
我正在为视频管理构建一个包含脚本字段的cms.transcript字段被发送到数据库,并且几乎总是有多个换行符("\n")字符.
我正在使用bootstrap运行rails 4.2.
可能不相关,但代码:
# Controller
class VideosController < ApplicationController
def show
@video = Video.find(params[:id])
end
end
# View (in haml)
.panel.panel-default
.panel-body
%p= @video.transcript
Run Code Online (Sandbox Code Playgroud)
有没有一种干净的方法来在html中正确渲染换行符?
我正在与Fog和Amazon s3合作管理视频和图像文件.我为我的文件设置content_type时遇到了很多麻烦.
在从控制台工作时,我能够通过并单独更新每个文件的content_type,然后运行save.但是,当我尝试对特定目录中的所有文件运行更新时,我没有收到错误,但没有任何更新.我运行了多种不同的方法,所有方法都具有相同的基本思想,并且所有设置都打印"已保存!" 如果文件保存.方法运行正常并打印出"已保存!",但当我返回并检查文件时,content_type仍为零.
这是我正在做的一个例子:
directory.files.each do |f|
case f.key.split(".").last
when "jpg"
f.content_type = "image/jpeg"
puts "saved!" if f.save
when "mov"
f.content_type = "video/quicktime"
puts "saved!" if f.save
end
end
Run Code Online (Sandbox Code Playgroud)
此外,当我通过并单独更新每个文件时,保存工作和content_type得到更新,但数据不会持久.
例如:
file = directory.files.first
file.content_type = 'video/quicktime'
file.save # returns true
file.content_type # returns 'video/quicktime'
Run Code Online (Sandbox Code Playgroud)
但是,当我在AWS中检查文件时,内容类型仍为零.
是否有更好的(持久的)方法来更新Fog s3文件上的content_type?我觉得我必须以错误的方式解决这个问题.
更新:尝试使用文件#copy方法:
directory.files.each do |f|
content_type = case f.key.split(".").last
when "jpg"
"image/jpeg"
when "mov"
"video/quicktime"
end
puts "copied!" if f.copy(f.directory.key, f.key, { 'Content-Type' => content_type })
end
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:
Excon::Errors::BadRequest: Expected(200) <=> Actual(400 …Run Code Online (Sandbox Code Playgroud) 我们试图测试我们的控制器根据我们的param调用一个给定次数的类,但我们的测试在rspec中失败,说我们类的initialize方法返回nil.
我们有这个控制器:
class ProcessFaxesController < ApplicationController
def create
email = params["From"]
attachment_count = params["attachment-count"].to_i
head :ok
if attachment_count > 0
attachment_count.times do |document_index|
FaxedDocumentProcessor.new(params, document_index+1).perform
end
else
DocumentProcessingMailer.delay.failure_notification(email, "No attachment found.")
end
end
end
Run Code Online (Sandbox Code Playgroud)
外部类:
class FaxedDocumentProcessor
def initialize(params, document_index)
@params = params
@attachment = @params["attachment-#{document_index}"]
@email = @params['From']
end
def perform
# some stuff here
end
end
Run Code Online (Sandbox Code Playgroud)
有了这个规范:
require 'rails_helper'
RSpec.describe ProcessFaxesController, type: :controller do
context "#create" do
context 'with attachments' do
before { allow_any_instance_of(FaxedDocumentProcessor).to receive(:perform).and_return(true) }
it 'calls …Run Code Online (Sandbox Code Playgroud)