草庐IT

update-dependency-configurations

全部标签

ruby - ruby < 2.3 的 `gem update --system` 是否损坏?

rubygems-update升级后的今天ruby早于2.3的gemupdate--system已经开始永久失败并出现下一个错误:#gemupdate--systemUpdatingrubygems-updateFetching:rubygems-update-3.0.0.gem(100%)ERROR:Errorinstallingrubygems-update:rubygems-updaterequiresRubyversion>=2.3.0.ERROR:Whileexecutinggem...(Errno::ENOENT)Nosuchfileordirectory@dir_chdi

ruby - Rails update_all 与 hstore

使用activerecord使用hstore列更新多条记录的好方法是什么?现在我正在像这样循环、更新和保存:time=Time.now.to_sscoped_tasks.eachdo|task|task.data[:last_checked]=timetask.save!end有什么方法可以用update_all查询来做到这一点吗?我见过的一种解决方案如下所示:MyModel.update_all(:properties=>ActiveRecord::Coders::Hstore.dump({'a'=>1}))但这样做的问题是它会覆盖整个列,因此其他值会丢失。我也看到了这个:MyMod

ruby-on-rails - Rails - update_column 和 ActiveRecord 枚举

我需要在我的Rails应用程序中使用update_column来防止运行回调。我有带枚举的ActiveRecord模型:classCar在正常情况下(即当我确实希望回调运行时)我可以使用类似的东西:@car.update_attribute:state,:not_used是否可以用update_column做类似的事情?我正在使用Rails4.2 最佳答案 update_column不将符号识别为枚举的变体。我认为您必须使用Car.states[:not_used]而不是:not_used。像这样:@car.update_colum

ruby-on-rails - 评估 :dependent => :destroy

在Rails2.2.2(ruby1.8.7-p72)中,我想在实际执行之前评估销毁对象的影响。IE。我希望能够生成将受:dependent=>:destroy影响的所有对象的列表(通过对象的关联)。我试图解决的真正问题是向用户提供将要删除的所有内容的列表,并让他们确认该操作。谁能推荐一个解决这个问题的好方法?我刚刚开始研究ActiveRecord::Associations,但还没有取得太大进展。更新:在我的特定情况下,我有各种级别的对象(A-->B-->C)。 最佳答案 这应该可以帮助您入门...显然您必须对其进行自定义,但这列出

ruby-on-rails - Rails 4 错误:ActionController::ParameterMissing in UsersController#update,找不到参数:用户

我有一个带有标准CRUD方法的用户Controller。其中一种方法是更新。defupdateif@user.update(user_params)redirect_to@user,notice:"AccountSuccessfullyupdated"elserender:editendend然后我有了rails4strongparams方法:privatedefuser_paramsparams.require(:user).permit(:name,:email,:password,:password_confirmation,:role_ids=>[])end我的观点是这样的::

ruby-on-rails - Rails 低级缓存 : Update cache when ActiveRecord object updated_at changes OR when a new object is added to collection

Rails附带片段缓存和低级缓存。片段缓存的工作原理非常清楚:Railswillwriteanewcacheentrywithauniquekey.Ifthevalueofupdated_athaschanged,anewkeywillbegenerated.ThenRailswillwriteanewcachetothatkey,andtheoldcachewrittentotheoldkeywillneverbeusedagain.Thisiscalledkey-basedexpiration.Cachefragmentswillalsobeexpiredwhentheviewfr

ruby-on-rails - RoR - Model.all,但没有 created_at 和 updated_at 字段

这个问题在这里已经有了答案:Rails4-Remove"created_at"and"updated_at"fromrender(2个答案)关闭5年前。我是Ruby的新手,所以这个问题对你来说可能看起来很愚蠢,是的。但还是...我有一个模型组,当我运行这个classGroupsController...然后我收到这样的数组响应:[{"id":1020,"name":"НІ-16-1","has_subgroups":true,"created_at":"2017-09-29T10:14:08.000Z","updated_at":"2017-09-29T10:14:08.000Z"}.

ruby-on-rails - ActiveModel::ForbiddenAttributesError 使用 update_attributes 自己创建了参数散列

我正在尝试使用simple_form编辑/更新模型记录,但该表单不会直接更改模型字段。相反,我提供了几个check_box_tag字段来告诉更新哪些字段需要更改。因此,update没有收到我可以用来更新属性的params[:device]散列。我正在尝试创建此哈希,但在发出@device.update_attributes(params[:device])时收到ForbiddenAttributesError。我相信我的强参数列表是正确的。如果我允许在编辑View中处理一个模型字段(名称),我会收到预期的params[:device]散列并且一切正常。如果我禁用该字段,因为我不希望它被

ruby-on-rails - TinyTDS : Server name not found in configuration files

我一直看到这个错误,我无法连接到远程服务器上的数据库。我得到了一个数据库连接字符串,如下所示:datasource=qsss.gar.de\SQL2012,3000;initialcatalog=City;persistsecurityinfo=True;userid=user_me;password=user_me##2009;现在,我已经根据该连接字符串创建了一个database.yml文件,如下所示:development:adapter:'sqlserver'host:'qsss.gar.de\SQL2012,3000'port:1433database:'City'usern

ruby-on-rails - ruby rails : Using shovel operator to update a string attribute on a model does not make the model dirty

今天我们遇到了一个有趣的问题。似乎如果您使用shovel运算符连接ActiveRecord模型上的字符串属性,它不会使模型变脏。例如:e=Employee.firste.name这是有道理的,因为shovel运算符更新字符串而不复制它,而+=运算符将复制字符串。如果您使用shovel运算符,我不明白ActiveRecord怎么可能知道发生了什么变化。有没有人看过这个?是只使用+=的解决方案吗?而不是连接字符串时? 最佳答案 解决方案是您编写。或者你可以在此之前标记你的态度will_changee=Employee.firste.na