我在shell中,我有这个字符串: 12 BBQ ,45 rofl, 89 lol
使用正则表达式:\d+ (?=rofl)我想要45的结果.
使用正则表达式从字符串中提取数据是否正确?我所做的最好的是突出一些在线正则表达式编辑器的价值.大多数情况下它会从我的字符串中删除值.
我正在调查expr,但我得到的只是语法错误.
如何设法在shell脚本中提取45?
我安装了邪恶的PDF并修改了我的控制器:
def show
respond_to do |format|
format.pdf do
render :pdf => "file_name"
end
format.html
end
end
Run Code Online (Sandbox Code Playgroud)
以下是我如何链接到pdf: compte_contrat_path(c,:format=>'pdf')
它适用于html(没有格式)但对于PDF失败,出现以下错误:
模板丢失了
Missing template contrats/show with {:locale=>[:fr], :formats=>[:pdf], :handlers=>[:erb, :builder, :coffee, :arb]}. Searched in:* "/home/sylario/ruby/place_de_marche/app/views"* "/usr/local/rvm/gems/ruby-1.9.2-p136/gems/activeadmin-0.5.0/app/views" *"/usr/local/rvm/gems/ruby-1.9.2-p136/gems/kaminari-0.14.1/app/views"*"/usr/local/rvm/gems/ruby-1.9.2-p136/gems/devise-2.2.0/app/views"
What am I doing wrong?
我正在尝试在我的prod服务器上使用wicked_pdf,但它仍然令人心烦:
RuntimeError (Failed to execute:
"/usr/bin/wkhtmltopdf" -q "file:////tmp/wicked_pdf20130709-23109-1adqx5g.html" "/tmp/wicked_pdf_generated_file20130709-23109-1ic5dbe.pdf"
Error: PDF could not be generated!
Command Error: wkhtmltopdf: cannot connect to X server
):
app/controllers/contrats_controller.rb:15:in `block (2 levels) in show'
app/controllers/contrats_controller.rb:11:in `show'
Run Code Online (Sandbox Code Playgroud)
我试着按照这个答案:wkhtmltopdf:无法连接到X服务器,但它仍然无法正常工作.
我有一个使用CKeditor的rails 4应用程序.在开发模式下,它工作正常,但在生产中,ckeditor不是apear,并且在textarea的位置有一个空白区域.
根据日志,缺少以下文件:
ActionController::RoutingError (No route matches [GET] "/assets/ckeditor/styles.js")
Run Code Online (Sandbox Code Playgroud)
如果我预编译资产,我可以看到生成以下文件:
public/assets/ckeditor/styles-65fee53acf063b3d207bc00b4f7ce0d5.js
Run Code Online (Sandbox Code Playgroud)
这是我的application.rb的ckeditor行:
config.assets.precompile += Ckeditor.assets
Run Code Online (Sandbox Code Playgroud)
看来这是CKeditor想要的文件,但它不是在寻找预编译的文件.我该如何解决这个问题?
我有属于收藏品的产品.集合只是一个名称.产品有collection_id.
在我用于创建和编辑产品的_form视图中,我想要一个带有所有集合名称的下拉菜单.
问题,似乎没有附加到form.for的选择方法,我试图使用:
select(method,choices,options = {},html_options = {})
从文档但我不明白.我必须写一个方法来创建一个表单?有哪些选择,有两种选择?两个参数应足以填充<option>标记.
我怎么能有一个下拉菜单让我通过集合名称为我的产品分配一个集合?
我想在提交按钮中转换由图像+文本(用于翻译)组成的div.可能吗?
我设法使用图像作为提交,但文本不是链接,它给整个图像+文本带来"破碎"的感觉
i18n在rails 3.0.3项目中配置:
config.i18n.default_locale = :fr
Run Code Online (Sandbox Code Playgroud)
在我的开发环境中,一切正常,价格为€和正确显示的文本(如下一个来自will_paginate).
在生产环境中,一切都是英语和$.
我在哪里可以找到我的i18n的问题?
i18n在制作中我错过了什么?
更多信息:
在rails控制台生产中的生产服务器上:
irb(main):002:0> I18n.config.default_locale
=> :fr
Run Code Online (Sandbox Code Playgroud)
2Nd编辑
有没有办法在调试或视图中显示I18n属性或配置?
我想创建一个带有函数库的静态ruby类.我在Vista上使用ruby 1.9.2
我的课就是这个:
class TestClass
def say_hello
puts "say hello"
end
end
Run Code Online (Sandbox Code Playgroud)
在一个TestClass.rb文件中(我假设我是正确的,因为所有关于类的ruby教程都是一个完整的混乱,把所有东西放在一个神奇的东西(文件?),好像IRB是所有事情的开始和结束).
我的ruby main()(是的,我来自Java)或程序入口或者在ruby中调用它是:
require 'TestClass.rb'
puts "start"
say_hello
Run Code Online (Sandbox Code Playgroud)
但它失败了:
C:\ruby_path_with_all_my_classes>ruby classuser.rb
<internal:lib/rubygems/custom_require>:29:in `require': no such file to load --
TestClass.rb (LoadError)
from <internal:lib/rubygems/custom_require>:29:in `require'
from classuser.rb:1:in `<main>'
Run Code Online (Sandbox Code Playgroud)
它是如何工作的?是否可以在Ruby中调用其他文件,或者只包含一个包含所有类的文件?
使用rails 3.0.3,我decimal使用以下迁移迁移了我的基础中的列:
change_table :products do |t|
t.change :price, :decimal, :precision => 10, :scale => 2
# other code
end
Run Code Online (Sandbox Code Playgroud)
迁移工作正常,但我仍然可以存储像4.64564这样的值,它应该只存储4.65
最重要的是,除了我创建的迁移文件之外,schema.rb不包含有关比例/精度的信息.
为什么rails接受精度/规模迁移忽略它?
我的表有以下CSS:
table{
border: 1px solid black;
border-collapse: collapse;
}
tr{
border-bottom: 1px solid #a2a2a2;
}
Run Code Online (Sandbox Code Playgroud)
我希望我的桌子有一个黑色边框和内部,该线应该用灰色边框分隔.然而,表的底部边框被tr覆盖,并且是灰色而不是黑色.
如何设置优先于tr边框的表格边框?
wicked-pdf ×2
assets ×1
border ×1
ckeditor ×1
class ×1
css ×1
css-tables ×1
decimal ×1
file ×1
foreign-keys ×1
forms ×1
html ×1
pdf ×1
pdfkit ×1
regex ×1
ruby ×1
shell ×1
templates ×1
wkhtmltopdf ×1