草庐IT

template-specialization

全部标签

ruby-on-rails - 子域 + ActionView::Template::Error(缺少要链接的主机!)

我已经解决了标题中描述的错误的众多解决方案。ActionView::Template::Error(缺少要链接的主机!请提供:host参数,设置default_url_options[:host],或将:only_path设置为true):但是,该项目还修改了url_for函数以使用子域,如本railscast所示:http://railscasts.com/episodes/221-subdomains-in-rails-3因此,这个错误的传统答案,例如在我的环境设置中设置变量似乎不是解决方案。这里有一些其他的提示:这是一个全新的设置,我刚刚克隆了一个项目并安装了ruby​​、rai

ruby-on-rails - Rails 和 I18n : localized templates vs localized string

您可能知道,从Rails2.2开始,Rails附带了一个简单的本地化和国际化后端。默认情况下,您可以将需要翻译的字符串存储在config文件夹中的本地化文件中。config/locales/en.ymlconfig/locales/it.yml但是Rails也提供了本地化模板和局部的能力。例如,MainController#index操作可以根据模板文件名和当前区域设置选择本地化模板。apps/views/main/index.it.html.erbapps/views/main/index.en.html.erb当您需要翻译单个字符串或短段落时,第一个功能很有用。当同一Action根

ruby-on-rails - 目录 : template missing error while rendering JSON

我的Controller中有以下代码:deftljson(result=[])@stat_id=params[:stat_id]@rpm=FedoraRpm.find_by_name(@stat_id)@rpm.ruby_gem.historical_gems.each{|h|resulth.version,:start=>h.build_date}}@rpm.bugs.each{|b|resultb.name+"ViewonBugZilla",:start=>b.bz_id}}@res=result.to_jsonrespond_todo|format|format.json{ren

ruby-on-rails - rails : calling yield in a partial template?

我有时会在部分erb模板中看到这个:其他时候根本没有yield。在局部调用yield有什么好处? 最佳答案 我过去曾使用过它,如果我有一个可以从不同页面调用的部分,可能需要页面中的一些上下文内容。我的一个用例是菜单。我有我的库存菜单项,但后来我有一个yield(:menu),这样用户加载管理页面的内容,我就可以从页面添加菜单项,而不是在其中编写条件语句部分本身。这是一些伪代码:_menu.haml%ul%liHome%liUsers%liRoles=yield(:menu)用户.haml-content_for:menudo%liA

ruby-on-rails - ActionView::Template::Error(application.css 未预编译):

我以前在heroku上开发过几个应用程序,从来没有遇到过这个错误:ActionView::Template::Error(application.css未预编译):我最新的推送甚至没有对application.css文件进行更改。这是怎么回事?我看到文章说将production.rb中的一行更改为:#Don'tfallbacktoassetspipelineifaprecompiledassetismissedconfig.assets.compile=true但这不会减慢一切吗?为什么会突然出现这个错误?修复它的最佳方法是什么?编辑:我应该注意到它在开发中工作得很好。

ruby-on-rails - RSpec Controller 测试 : missing template on create

我有一个有趣的情况。我正在测试以下简单的创建操作:#willonlybeaccessedviaAjaxdefcreateclick=Click.new(params[:click])click.save#don'treallycarewhetheritssuccessorfailureend然后我有以下非常简单的Controller规范:require'spec_helper'describeClicksController,"creatingaclick"doit"shouldcreateaclickforevent"doxhr:post,:create,:click=>{:even

sql - ActionView::Template::Error (PG::UndefinedFunction: ERROR: operator does not exist: integer ~~ 未知

为了在Heroku中使用,我从MySQL切换到了PostgreSQL。现在我的搜索不起作用。无法弄清楚运营商出了什么问题。ActionView::Template::Error(PG::UndefinedFunction:ERROR:operatordoesnotexist:integer~~unknown.2014-11-11T19:59:58.082607+00:00app[web.1]:ProcessingbyAllListingsController#search_listingsasJS2014-11-11T19:59:58.105074+00:00app[web.1]:4:

ruby-on-rails - 尝试将本地数据库推送到 Heroku 后出现 "ActionView::Template::Error (Unknown primary key for table"

对于我通过Heroku托管的Ruby-on-Rails应用程序,我最近下载了一个备份,在本地恢复它,然后从外部来源将数据添加到数据库中。一切正常。在使用herokupg:pushHEROKU_DATABASE_URL--app将更新后的数据库推送到Heroku之后该应用程序运行良好,我可以看到新添加的数据。但是今天当我尝试在Heroku上登录该应用程序时,我收到了错误消息。在我的日志文件中,我看到了这个错误:ActionView::Template::Error(Unknownprimarykeyfortable...根据这篇SO帖子:Getting"Unknownprimarykey

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/