草庐IT

load_value

全部标签

ruby-on-rails - 在 RSpec 中获取 'Bad value for range'

这是我的代码:#app/models/user.rbclassUser:modeldolet(:user){FactoryGirl.create:user}it"shouldreturnthecorrectdisplayname"doexpect(user.display_name).toeql("Chuck")endend#spec/factories/users.rbFactoryGirl.definedofactory:userdoprovider"MyString"uid"MyString"name"ChuckNorris"oauth_token"MyString"oauth_

ruby - Homebrew 软件损坏 - "cannot load such file -- vendor/bundle/bundler/setup (LoadError)"

每次我尝试运行brew命令时,都会出现以下错误:/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.7/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in`require':cannotloadsuchfile--vendor/bundle/bundler/setup(LoadError)from/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.7/lib/ruby/2.3.0/r

ruby - Chef : cannot load such file -- moneta/basic_file

我正在运行一个我以前使用过无数次的Recipe,当我用chef+knife启动一个新的EC2实例时,我遇到了这些错误。[2013-01-30T23:44:48+00:00]INFO:Processinguser[dan]actioncreate(/var/chef/cache/cookbooks/users/providers/manage.rbline65)[2013-01-30T23:44:48+00:00]INFO:user[dan]created[2013-01-30T23:44:48+00:00]INFO:Processingdirectory[/home/dan/.ssh]

ruby-on-rails - YAML::load 引发未定义的类/模块错误

我正在我的Rails应用程序中实现类似文件跟踪的功能。为此,我在YAML中序列化对象。我有item_at_version方法,它基本上执行YAML::load(cached_object)–这工作得很好,但是,我不知道为什么,有时它返回未定义的类/模块_类名_。它适用于Event、Conversation、Note等模型,但没有任何理由,它似乎会为Dataset、Comment、Student等模型抛出该错误(我试图找到任何模式,但没有任何运气).我正在使用rails3.2.8、ruby1.9.3p327、psych作为YAML引擎(Psych::Version返回1.3.4)。附言。

ruby-on-rails - 事件管理员 :select drop-down defaults to current value in development but defaults to blank in production

我有以下ActiveAdmin表单:formdo|f|f.inputs"TimesheetDetails"dof.input:jobs_assigned_worker,:label=>"Worker",as::select,collection:Worker.allf.input:worked_time_hours,:label=>"WorkedTime(Hours)"f.input:worked_time_mins,:label=>"WorkedTime(Minutes)"f.input:driving_time_hours,:label=>"DrivingTime(Hours)"f

ruby-on-rails - rails 4 : Forcing specific values with "strong parameters"

我正在努力使用用于创建“项目”的表单。最后,我只想允许当前的user_id,但我还没有构建用户模型或身份验证,因此作为占位符,我只是硬编码1。app/views/projects/new.html.erb:{:action=>'create'})do|f|%>1})%>app/controllers/projects_controller.rbdefcreate#saveobjectifProject.create(project_params)redirect_to(:action=>'show')elserender('new')endendprivatedefproject_pa

ruby-on-rails - rails/ ruby : TimeWithZone comparison inexplicably failing for equivalent values

我在当前项目中比较DateTime时遇到了一段糟糕的时光(没有双关语意),特别是比较ActiveSupport::TimeWithZone的两个实例。问题是我的两个TimeWithZone实例具有相同的值,但所有比较都表明它们不同。执行调试时暂停(使用RubyMine),可以看到如下信息:timestamp={ActiveSupport::TimeWithZone}2014-08-0110:33:36UTCstarted_at={ActiveSupport::TimeWithZone}2014-08-0110:33:36UTCtimestamp.inspect="Fri,01Aug20

ruby - kernel_require.rb :55:in `require' : cannot load such file error

我目前使用的是Ruby1.9.3版(尽管我在使用Ruby2.0.0时遇到了同样的问题)。在Windows764位上。我正在关注“TheCucumberBook”并卡在第7.2章-“使用转换删除重复项”。我的文件夹结构如下:\cash_withdrawal\cash_withdrawal\Gemfile\cash_withdrawal\Gemfile.lock\cash_withdrawal\features\cash_withdrawal\features\cash-withdrawal.feature\cash_withdrawal\features\step_definitions

ruby-on-rails - 为什么都是autoload,load_all!并要求全部用于 active_support.rb?

我正在查看active_support.rb以尝试了解它使用的加载过程。它使用三种加载方法:load_all!、autoload和require。为什么在同一个文件中使用三种不同的加载方式?moduleActiveSupportdefself.load_all![Dependencies,Deprecation,Gzip,MessageVerifier,Multibyte,SecureRandom,TimeWithZone]endautoload:BacktraceCleaner,'active_support/backtrace_cleaner'autoload:Base64,'ac

ruby-on-rails - Rails 控制台 : in `require' : cannot load such file -- readline (LoadError)

我的Rails应用程序出现一些错误,我正在尝试通过发出以下命令来启动Rails控制台:railsconsole无论我尝试什么,我总是得到同样的错误:/usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/irb/completion.rb:9:in`require':cannotloadsuchfile--readline(LoadError)from/usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/irb/completion.rb:9:in`'from/opt/mammie/web/icosole