草庐IT

config-store

全部标签

ruby - Jekyll Liquid - 动态访问 _config.yml

为了使我的应用国际化,我需要能够动态访问YAML文件中的条目。最好用一个例子来解释:页面:---layout:defaulttitle:title_homepage---这将允许访问默认布局模板中的title_homepage变量:默认布局:page.title="title_homepage"现在通常我会像这样访问我的_config.yml文件:{{site.locales[site.default_locale].variable}}但是,现在要让它工作,我需要使用page.title的值访问_config.yml。这是行不通的:{{site.locales[site.defaul

ruby - Sinatra - 通过 config.ru 设置缓存控制 header

我目前正在Heroku的Cedar堆栈上运行一个Octopress(基于Jekyll)站点——代码位于此处:https://github.com/elithrar/octopress我想根据文件类型有选择地应用Cache-Controlheader:.html文件获取值public,max-age=3600.css|.js|.png|.ico(等)获得public,max-age=604800的值-或者,我想将此规则应用于/stylesheets'、'/javascripts'、'/imgs'目录提供的任何内容。同时使用了set:static_cache_control,[:publi

ruby - heroku 上的非 Rails 应用程序的 config.ru 中有什么内容?

我有一个使用resque的简单ruby​​(非rails)应用程序,如果没有heroku上的config.ru就无法启动。当我添加config.ru文件时,在本地运行rackup时出现以下错误:/usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/rack-1.5.2/lib/rack/builder.rb:133:in`to_app':missingrunormapstatement(RuntimeError)from/Users/nickkarrasch/Dropbox/Coding/Ruby/smsnotifyv2/

ruby - 从 config.ru 设置 Sinatra 应用设置

当我使用Sinatra作为Rack中间件时,我可以在我的Rackup文件中这样做:useMyGloriousApp.newdo|le_app|le_app.settings.set:frobnicate,trueend当我需要中间件末尾的runblock时,我该如何完成相同的操作链?有点像runMyGloriousApp.newdo|le_app|le_app.settings.set:frobnicate,trueend 最佳答案 这是由创建block时do...end语法的优先级引起的。你的例子:runMyGloriousApp

ruby - Watir Webdriver : Iterating table and storing its content in an array

我正在尝试自动化显示在网站上的block并通过CMS表比较其内容。问题是我已经设法使出现在UI上的block自动化,但是当我以管理员身份登录并尝试使用迭代将表的内容保存在一个数组中时,我无法做到这一点。NewText12012-06-0610:241Text22012-06-0610:292ThisisText32012-06-0512:553我使用的代码是@text=Array.newx=1y=0untilx==10y=x-1untily==x@text[y]=@browser.table(:id,'nodequeue-dragdrop').tbody.row{x}.cell{1}.

ruby - Gem 不加载 config.ru

我有自己的gem“RocketRuby”。我将它加载到irb中,它可以加载它。在较早的版本中,我的config.ru中也有它并且有效。现在我又编译了一遍,又安装了一遍。然后(它仍然通过将其加载到irb中来工作)乘客崩溃并告诉我:cannotloadsuchfile--rocketruby(LoadError)/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:60:in`require'/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:60:in`rescueinrequire'/usr/lib/ru

ruby-on-rails - rails config/environments 'config' 在哪里定义?

在config/environments/production.rb(和其他环境)中有:config.eager_load=true和一大堆其他config.foobar调用。但是“配置”从何而来?通常你有这样的东西:SomeClass.eachdo|block_variable|block_variable.some_methodend但对于神秘的“配置”,情况并非如此,它就像一个未在任何地方声明的block变量。打开Rails控制台,当我这样做时:irb(main):001:0>configNameError:undefinedlocalvariableormethod`confi

ruby - Heroku 上没有这样的文件 'config/database.yml'

我的应用是一个RubyRack应用。当我的Heroku应用程序启动时它中断了,因为/app/config.ru:8:in`read':Nosuchfileordirectory-config/database.yml(Errno::ENOENT)为什么会这样?我知道Heroku是为了创建这个文件https://devcenter.heroku.com/articles/cedar-migrationThedatabasecredentialswillstillbeconfiguredautomatically:atslugcompiletime,aconfig/database.yml

ruby-on-rails - 如何跳过 config.middleware.use 用于 Rails 5 中的特定 Controller 操作

有没有办法设置config.middleware.use来排除/忽略/跳过特定的Controller操作?例如,如果我想排除Post#showController操作。我正在使用https://github.com/railslove/rack-tracker测试GoogleAnalytics/标签管理器。#RackTrackerconfigconfig.middleware.use(Rack::Tracker)dohandler:google_tag_manager,{container:ENV['GTM_CONTAINER_ID']}end我想我可以使用这样的条件:#RackTra

ruby-on-rails - Ruby On Rails 4 会默认将 config.active_record.whitelist 属性设置为 true 吗?

RoR4是否会默认将config.active_record.whitelist_attributes设置为true和其他一些证券值?现在我认为RoR已经足够简化,可以出于安全原因集成此类约束。谢谢 最佳答案 到目前为止,是的——检查一下:https://github.com/rails/rails/blob/master/railties/lib/rails/generators/rails/app/templates/config/application.rb#L57#Enforcewhitelistmodeformassass