草庐IT

ENV_NAME

全部标签

ruby-on-rails - 迁移正在等待;运行 'bin/rake db:migrate RAILS_ENV=development' 来解决这个问题[无法继续]

我似乎有一个关于RubyonRails迁移过程的循环问题。我正在关注介绍文章,我已经到了需要创建我的第一个表的地步。我已经运行了以下,[tims@web2working_ror]#railsgeneratemodelHomepagefirst_name:stringlast_name:stringemail:stringmessage:textinvokeactive_recordcreatedb/migrate/20131119203948_create_homepages.rbcreateapp/models/homepage.rbinvoketest_unitcreatetest

ruby-on-rails - Rails 4 迁移 : has_and_belongs_to_many table name

我目前正在尝试将Rails3.2应用程序切换到Rails4.0。但是我对has_and_belongs_many模型有一个问题。我创建了一个测试应用程序,但我遇到了同样的问题。这就是我所做的:创建了两个模型:foo_clip和foo_urlclassFooClip在此之后我更新了迁移文件:classCreateFooClips现在我已经为has_and_belongs_to_many表创建了迁移文件classCreateFooClipsFooUrls作为最后一步,我创建了一个用于测试的种子文件:foourl1=FooUrl.create!(:url=>'http://www.googl

ruby-on-rails - 在 env.rb 之外需要 Cucumber-rails。其余的加载被推迟到 env.rb 被调用

请问这个env.rb错误是什么意思?root#rakedb:migrateWARNING:Cucumber-railsrequiredoutsideofenv.rb.Therestofloadingisbeingdefereduntilenv.rbiscalled.Toavoidthiswarning,move'gemcucumber-rails'underonlygroup:testinyourGemfilegemfile在这里:source'http://rubygems.org'gem'rails','3.1.0'#BundleedgeRailsinstead:#gem'rail

ruby-on-rails - Rails 4 + Devise : Invalid route name, 已在使用中

我正在按照此操作方法在成功注册后修改确认页面。https://github.com/plataformatec/devise/wiki/How-To:-Redirect-to-a-specific-page-on-successful-sign-up-(registration)我按照它所说的做了所有事情,但我得到了这个错误:in`add_route':Invalidroutename,alreadyinuse:'new_user_session'(ArgumentError)Youmayhavedefinedtworouteswiththesamenameusingthe`:as`o

关于Document mapping type name can‘t start with ‘_‘, found: [_update]

在修改elasticsearch时,用_update进行局部修改,修改失败,报错{    "error": {        "root_cause": [            {                "type": "invalid_type_name_exception",                "reason": "Document mapping type name can't start with '_', found: [_update]"            }        ],        "type": "invalid_type_name_exce

ruby - 冒号(:) appears as forward slash (/) when creating file name

我正在使用日期和时间来标记我正在创建的新文件,但是当我查看该文件时,冒号是一个正斜杠。我正在使用10.7+在Mac上开发这是我使用的代码:File.open("#{time.hour}:00,#{time.month}-#{time.day}-#{time.year}","a")do|mFile|mFile.syswrite("#{pKey}-#{tKey}:\n")mFile.syswrite("Itemsclosed:#{itemsClosed}|Totalitems:#{totalItems}|Percentclosed:%#{pClosed}\n")mFile.syswrite

ruby-on-rails -/usr/bin/env ruby​​ 没有这样的文件或目录 : Using capistrano 3, capistrano/rbenv、capistrano/bundler 和 capistrano/rails(使用 rails 4)

我正在使用capistrano、capistrano/rbenv、capistrano/bundler和capistrano/rails。我在capistrano编译Assets的步骤中得到这个错误:DEBUG[49a50df6]/usr/bin/env:DEBUG[49a50df6]rubyDEBUG[49a50df6]:NosuchfileordirectoryDEBUG[49a50df6]在生产服务器中/usr/bin/envruby​​-v是正确的。我知道这一点:why-does-something-work-in-my-ssh-session-but-not-in-capis

ruby-on-rails - 我如何在 rake 任务中强制使用 RAILS_ENV?

我有这个小佣金任务:namespace:dbdonamespace:testdotask:resetdoENV['RAILS_ENV']="test"Rake::Task['db:drop'].invokeRake::Task['db:create'].invokeRake::Task['db:migrate'].invokeendendend现在,当我执行时,它将忽略我尝试硬编码的RAILS_ENV。我如何使这个任务按预期工作 最佳答案 对于这个特定的任务,您只需要更改数据库连接,正如Adam指出的那样,您可以这样做:namesp

Ruby:如果存在 ENV 变量,则使用最简洁的方法,否则使用默认值

在Ruby中,我正在尝试编写一行,如果已设置变量,则使用该变量,否则默认为某个值:myvar=#assignittoENV['MY_VAR'],otherwiseassignitto'foobar'我可以这样写这段代码:ifENV['MY_VAR'].is_set?#whateverthefunctionistocheckifhasbeensetmyvar=ENV['MY_VAR']elsemyvar='foobar'end但这有点冗长,我尽量用最简洁的方式来写。我该怎么做? 最佳答案 myvar=ENV['MY_VAR']||'f

ruby - map(& :name) mean in Ruby? 是什么意思

我在aRailsCast中找到了这段代码:deftag_names@tag_names||tags.map(&:name).join('')endmap(&:name)中的(&:name)是什么意思? 最佳答案 它是tags.map(&:name.to_proc).join('')的简写如果foo是一个带有to_proc方法的对象,那么你可以将它作为&foo传递给一个方法,它将调用>foo.to_proc并将其用作方法block。Symbol#to_proc方法最初由ActiveSupport添加,但已集成到Ruby1.8.7中。这