我将应用程序从3.2.12切换到4.0.0.rc1.当我之后在制作中看到它时,背景图像消失了.我的其他图像资源都没有问题.
在我的日志中,我看到所有成功渲染的图像都有一个摘要添加到它们的末尾,如下所示:
2013-05-12T19:57:05.856277+00:00 heroku[router]: at=info method=GET path=/asset/explore-9ec2a1cfd4784133755637f6ef6d5673.png host=xxx.herokuapp.com fwd="69.140.148.75" dyno=web.1 connect=3ms service=5ms status=200 bytes=4064
Run Code Online (Sandbox Code Playgroud)
我的不成功的背景图片没有摘要,加上404响应代码:
2013-05-12T19:57:05.736354+00:00 heroku[router]: at=info method=GET path=/assets/background.png host=xxxx.herokuapp.com fwd="69.140.148.75" dyno=web.1 connect=2ms service=7ms status=404 bytes=728
Run Code Online (Sandbox Code Playgroud)
在production.rb文件中,有一个配置行,用于缓存目的:
# Generate digests for assets URLs
config.assets.digest = true
Run Code Online (Sandbox Code Playgroud)
这是后台的CSS:
body {
background-image: url('background.png');
background-attachment: fixed;
background-position: 100% 100%;
background-repeat: no-repeat;
}
Run Code Online (Sandbox Code Playgroud)
我得出结论,我的CSS文件试图获取一个不存在的图像URL,因为它引用了普通资产("background.png")而没有最后的哈希.这只是CSS中图像的一个问题; 我的.erb文件中引用的所有图像都可以.那么如何在我的CSS中引用这个资产而不用硬编码摘要呢?有没有解决方法?
谢谢阅读.
我有一个带有图像属性的Artwork模型,其中安装了Carrierwave.在编写控制器规范时,我意识到图像字段保持空白,即使我认为我传入的是文件对象.
我的调试信息告诉我问题是我安装了CarrierWave的图像属性,而不是其他东西.我不认为我传递了它需要的信息,但我不知道该尝试什么.
这是控制器操作,带有一些调试信息来识别问题:
def create
@artwork = @imageable.artworks.new(params[:artwork])
logger.debug "Artwork should be valid: #{@artwork.valid?}"
logger.debug "Errors: #{@artwork.errors.full_messages}"
if @artwork.save
flash[:success] = "Artwork created."
redirect_to [@imageable, :artworks]
else
flash[:error] = "Artwork not created."
render :new
end
end
Run Code Online (Sandbox Code Playgroud)
在测试日志中,我在运行我的规范后看到了这个:
Processing by ArtworksController#create as HTML
Parameters: {"artwork"=>{"image"=>"#<File:0x4515480>", "title"=>"Portrait","year"=>"2012", "surface_type"=>"canvas", "size"=>"10 x 10", "price"=>"100.0", "for_sale"=>false, "prints_available"=>false, "notes"=>"extra notes"}, "file"=>"#<File:0x46c6938>", "originals_gallery_id"=>"1"}
[1m[36mOriginalsGallery Load (0.0ms)[0m [1mSELECT "originals_galleries".* FROM "originals_galleries" WHERE "originals_galleries"."id" = ? LIMIT 1[0m [["id", "1"]]
Artwork should be valid: false
Errors: ["Image can't be …Run Code Online (Sandbox Code Playgroud) 我正在编写一个脚本,使用表单中的文本输入进行计算.出于某种原因,我的计算仅在每页加载时执行一次.当我按下"计算"按钮时,我必须刷新页面以使功能再次运行.
这是我的按钮的HTML:
<input type="button" value="Calculate" onclick="calculate(high, low, common);" />
<input type="reset" />
<div id="result"></div>
Run Code Online (Sandbox Code Playgroud)
这是计算函数(变量在别处定义):
var calculate = function (high, low, common) {
if (high.length < 1 || low.length < 1 || common.length <1) {
document.getElementById('result').innerHTML="Please enter a number for all fields.";
} else {
if ((high - common) > (common - low)) {
document.getElementById('result').innerHTML="Result 1.";
} else if ((common - low) > (high - common)) {
document.getElementById('result').innerHTML="Result 2.";
} else if ((common - low) === (high - common)) { …Run Code Online (Sandbox Code Playgroud) 使用Cloudinary及其Carrierwave插件,我可以在我的视图中编写一个表单,将图像上传到他们的云并将其绑定到名为的模型属性picture,如下所示:
<%= form_for(@post) do |post_form| %>
<%= post_form.hidden_field(:picture_cache) %>
<%= post_form.file_field(:picture) %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
这有效.但我无法弄清楚如何将属性绑定到模型,同时遵循他们在Rails中直接上传的文档.他们的示例使用未绑定到模型的form_tag:
<%= form_tag(some_path, :method => :post) do %>
<%= cl_image_upload_tag(:image_id) %>
...
<%= end %>
Run Code Online (Sandbox Code Playgroud)
我正在寻找一些类似的例子<%= post_form.some_upload_method(:picture) %>.有没有其他人这样做直接上传他们的模型,知道我在找什么?
是否有一个保留的查询字符串字符,通常用于忽略字符串的各个部分?像这样的东西:
?foo=bar&baz=quux*some character*&sky=blue
Run Code Online (Sandbox Code Playgroud)
在此查询字符串中添加一些字符结果,并忽略结束:
?foo=bar&baz=quux
Run Code Online (Sandbox Code Playgroud)
我知道通常由解析查询字符串的程序决定如何处理任何内容,但我想知道这样的事情是否存在与a表示空格的方式相同.
carrierwave ×1
cloudinary ×1
forms ×1
function ×1
javascript ×1
query-string ×1
rspec ×1
url ×1