草庐IT

add_recipe

全部标签

ruby-on-rails - 从 ActiveAdmin has_many 表单助手中删除 "Add new"按钮

我在事件管理员编辑页面中有嵌套资源,但我只想允许管理员编辑现有资源的内容,而不是添加新的嵌套资源。我的代码看起来像这样:formdo|f|f.inputsdof.input:authorf.input:contentf.has_many:commentsdo|comment_form|comment_form.input:contentcomment_form.input:_destroy,as::boolean,required:false,label:'Remove'endendf.actionsend但它在输入下添加了“添加新评论”按钮。我怎样才能禁用它,并只为主窗体保留f.ac

ruby-on-rails - Rails add_index 算法 : :concurrently still causes database lock up during migration

为了防止在迁移到生产站点期间出现数据库事务错误,我们遵循了https://github.com/LendingHome/zero_downtime_migrations中列出的建议。(具体由https://robots.thoughtbot.com/how-to-create-postgres-indexes-concurrently-in概述),但在特别大的表上创建索引期间,即使是索引创建的“并发”方法也会锁定表并导致该表上的任何ActiveRecord创建或更新导致各自的事务失败有PG::InFailedSqlTransaction异常。下面是我们运行Rails4.2(使用Acti

ruby - 您如何模块化 Chef Recipe ?

这是一个工作配方示例,它循环访问网站名称数组并使用函数createIisWebsite()在IIS中创建它们。defcreateIisWebsite(websiteName)iis_sitewebsiteNamedoprotocol:httpport80path"#{node['iis']['docroot']}/#{websiteName}"host_header"#{websiteName}.test.kermit.a-aws.co.uk"action[:add,:start]endend在我们的实际解决方案中,这些数据存储在别处并通过WebAPI访问。websiteNames=[

ruby - apt Recipe 不会安装在我的 Recipe 中

我正在尝试使用Vagrant创建我的第一个ChefRecipe,但在第一步就遇到了问题。我的Recipe的第一行是:include_recipe"apt"但是当我尝试vagrantprovision时,出现以下错误:==>default:[2014-09-21T07:15:42+00:00]WARN:MissingCookbookDependency:==>default:Recipe`apt`isnotintherun_list,andcookbook'apt'==>default:isnotadependencyofanycookbookintherun_list.Toloadth

ruby - Chef : Can a variable set within one ruby_block be used later in a recipe?

假设我有一个变量directory_list,我在名为get_directory_list的ruby​​_block中定义和设置了它。我可以稍后在我的Recipe中使用directory_list吗,或者编译/收敛过程会阻止这种情况吗?例子:ruby_block"get_file_list"doblockdotransferred_files=Dir['/some/dir/*']endendtransferred_files.eachdo|file|file"#{file}"dogroup"woohoo"user"woohoo"endend 最佳答案

ruby-on-rails - 对于新的 ActiveRecord 模型,为什么有些 has_many :through associations add a (1=0) predicate and distinct clause to the sql query?

每当我实例化一个新的ActiveRecord模型(一个尚未持久化到数据库中的模型)并尝试访问构建模型上的一些各种关联时,Rails查询构建器有时会:将(1=0)谓词添加到查询的where子句。在select语句中添加“distinct”子句。我认为这只会在has_many:through关联连接两个或多个表时发生。我想知道为什么它添加了(1=0)谓词以及distinct子句。对于(1=0)谓词,新模型是否已保存到数据库应该无关紧要(对吧?)。我不知道为什么要添加distinct子句。我在下面有一个简单的例子。classAssignment#s.assignment_attachment

ruby - 如何在 Chef Recipe 中使用 not_if

我是Chef的新手,所以我对条件not_if在执行资源中的工作方式有些困惑。我知道如果命令返回0或true,它会告诉Chef不要执行命令;但是,在我的代码中,它显然仍在运行命令。下面的代码应该创建一个用户(及其密码)和一个数据库;然而,如果用户和数据库已经存在,它不应该做任何事情。用户、数据库和密码在属性中定义。以下是我的代码:execute"create-user"docode=Chef给我以下错误:在资源“execute[create-user]”上执行操作run时出错...[2013-01-25T12:24:51-08:00]致命:Mixlib::ShellOut::ShellC

ruby - 如何在 rails_admin 的编辑表单中隐藏 "Save and Add Another"按钮?

我在我的Rails应用程序中应用了rails_admingem。我想删除特定模型编辑表单中一些不必要的按钮,并添加我自己的自定义按钮。请查看屏幕截图,了解我要删除的内容。 最佳答案 @montells复制https://github.com/sferik/rails_admin/blob/master/app/views/rails_admin/main/_submit_buttons.html.haml这个页面在你的repo中,位于“views/rails_admin/main/_submit_buttons.html.haml”

ruby - 在 vagrant rbenv NoMethodError loaded_recipe 上安装 ruby​​ 1.9.3?

我正在尝试vagrant安装并希望将1.9.3-p327作为默认的ruby​​版本。我正在使用chef-solo和librarian-chef来管理vagrant机器。我为chef-solo配置的vagrant文件看起来像这样config.vm.provision:chef_solodo|chef|chef.cookbooks_path="cookbooks"chef.add_recipe"apt"chef.add_recipe"build-essential"chef.add_recipe"git"chef.add_recipe"ruby_build"chef.add_recipe"

ruby-on-rails - 攻击 ActiveRecord : add global named scope

我正在尝试为像这样的ActiveRecord模型提供一组非常通用的命名范围:moduleScopesdefself.included(base)base.class_evaldonamed_scope:not_older_than,lambda{|interval|{:conditions=>["#{table_name}.created_at>=?",interval.ago]}endendendActiveRecord::Base.send(:include,Scopes)classUser如果命名范围应该是通用的,我们需要指定*table_name*以防止命名问题,如果它们是来自