草庐IT

excel_template

全部标签

ruby-on-rails - rails : use jbuilder template in various controller methods

是否可以在另一个Controller方法中重用jbuilder-template?换句话说:如何明确地说Controller方法使用具体的jbuilder-template? 最佳答案 来自Railsguide.从另一个Controller渲染一个Action的模板。Whatifyouwanttorenderatemplatefromanentirelydifferentcontrollerfromtheonethatcontainstheactioncode?Youcanalsodothatwithrender,whichacce

ruby - 使用 template.erb 创建文件

我是ruby​​和chef的新手,我想知道是否有办法使用模板创建文件?我试着搜索它,但找不到太多东西。我尝试创建一个黑名单文件并通过Chef将一些正则表达式插入其中。所以我想添加属性并使用template.erb在运行chef时创建文件。有什么提示、指点吗? 最佳答案 Chef有一个名为template的特殊资源,从模板创建文件。您需要将您的模板放在templates/default目录下的cookbook中,然后在您的Recipe中使用它,并提供变量。cookbooks/my_cookbook/templates/default/

ruby - 如何使用 Rails 生成 Excel 文件?

我在Ruby工具箱中搜索一种流行的、得到良好支持的工具来生成XSLX(Excel2007及更高版本)文档,但我没有找到任何东西。我也花了很多时间在Google上搜索,但我找到的大部分答案似乎都过时了。我需要在生成的文档中包含内联图像。我正在使用Ruby1.9.2和Rails3。有什么建议吗?非常感谢! 最佳答案 比赛有点晚了,但你去吧。你应该使用axlsxgem在Github上:https://github.com/randym/axlsx关于Rubygems:https://rubygems.org/gems/axlsx在Ruby

ruby - 点击服务器错误 `<module:Templates>':未初始化常量 Tilt::CompileSite (NameError)

我正在尝试将我的sqlite3数据库迁移到postgresql,但我无法通过此错误。当我运行tapsserversqlite://db/development.sqlite3[user][password]我不断收到/Users/phillipjarrar/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sinatra-1.0/lib/sinatra/base.rb:298:in:uninitializedconstantTilt::CompileSite(NameError) 最佳答案

ruby - 如何使用 Ruby 读取 Excel 电子表格的内容?

我正在尝试使用Ruby读取Excel电子表格文件,但它没有读取文件的内容。这是我的脚本book=Spreadsheet.open'myexcel.xls';sheet1=book.worksheet0sheet1.eachdo|row|putsrow.inspect;putsrow.format2;putsrow[1];exit;end它给了我以下信息:[DEPRECATED]Byrequiring'parseexcel','parseexcel/parseexcel'and/or'parseexcel/parser'youareloadingaCompatibilitylayerwh

go-templates - 如何根据表达式有条件地在 Go 模板中设置变量,如果不使用 if 语句包装可能会导致错误

问题我该如何做这样的事情:{{$use_ssl:=(ne$.Env.CERT_NAME"")}}其中$.Env.CERT_NAME可能为零/未定义。如果它是零,它给出这个错误:at:errorcallingne:invalidtypeforcomparison注意:我无法控制传递给Go模板的对象,因此必须完全在模板本身内解决这个问题。我尝试过的我试图通过首先检查它是否为非空来变通:{{$use_ssl:=(($.Env.CERT_NAME)&&(ne$.Env.CERT_NAME""))}}但它给出了这个错误:unexpected"&"inoperand所以我切换到这个,这在语法上是允

ruby-on-rails - ActionView::Template::Error(不兼容的字符编码:UTF-8 和 ASCII-8BIT)

我正在使用Ruby1.9.2、Rails3.0.4/3.0.5和PhusionPassenger3.0.3/3.0.4。我的模板是用HAML编写的,我使用的是MySQL2gem。我有一个Controller操作,当传递一个具有特殊字符(如变音符号)的参数时,会出现以下错误:ActionView::Template::Error(incompatiblecharacterencodings:UTF-8andASCII-8BIT)错误指向我的HAML模板的第一行,其中包含以下代码:我的理解是,这是因为我有一个UTF-8字符串与一个ASCII-8BIT字符串连接在一起,但我终究无法弄清楚那个

ruby-on-rails - ActionView::Template::Error:缺少要链接到的主机

正如标题所暗示的,当我尝试在我的邮件程序模板中使用link_to时出现此错误:ActionView::Template::Error:Missinghosttolinkto!Pleaseprovidethe:hostparameter,setdefault_url_options[:host],orset:only_pathtotrue我尝试按照它的说明进行操作,并且还找到了thispost,但我仍然收到错误。我尝试将config.action_mailer.default_url_options={host:'example.com'}添加到以下每个文件,但没有一个有效:/confi

ruby-on-rails - Rails : render doesn't work, 仍然得到 `Template is missing`

我目前正在学习Rails指南。我完成了这些步骤,但仍然遇到错误。我的Ruby版本是ruby2.1.1p76,Rails版本是4.0.4。按照指南的指示,我创建了一个ArticleController。classArticlesController我应该得到{"title"=>"Firstarticle!","text"=>"Thisismyfirstarticle."但输出结果是TemplateismissingMissingtemplatearticles/create,application/createwith{:locale=>[:en],:formats=>[:html],:

ruby-on-rails - Rails - 使用 axlsx gem (Keep MVC) 将记录导出到可下载的 excel 文件

我已经从https://github.com/randym/axlsx成功安装了axlsxgem这是我用来通过这个gem创建excel文件的Controller代码。但是这段代码没有任何反应,而是显示了一个错误未初始化的mimeclassCoaches::PaymentsControllerparams[:page],:order=>sort_column+""+sort_direction)else@payments=Payment.includes(:member).paginate(:page=>params[:page],:order=>'iddesc')endrespond_