草庐IT

background-saving-is-failing-with

全部标签

ruby - 参数错误 : wrong number of arguments (1 for 0) when using afer_save

ArgumentError:wrongnumberofarguments(1for0)from/Users/Castillo/Desktop/gainer/app/models/status.rb:13:in`update_remaining_nutrients'from/usr/local/rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.11/lib/active_record/associations/collection_association.rb:507:in`blockincallback'from/usr/local/rvm/

ruby-on-rails - 葡萄 : required params with grape-entity

我正在用grape编写一个API服务器,我选择使用grape-entity因为它能够自动生成swagger的文档。但是现在我在按要求设置参数时遇到了问题。因为葡萄不验证参数是否存在。看起来grape忽略了实体参数的required:true。app.rbmoduleSmartmoduleVersion1classAppos_entity.rbmoduleSmartmoduleEntitiesclassOSEntityapp_entity.rbmoduleSmartmoduleEntitiesclassAppEntity现在其他一切都很好,但我不知道如何以DRY方式使用实体,并让grap

ruby-on-rails - rails : How to to download a file from a http and save it into database

我想创建一个RailsController,从网上下载一系列jpg文件,并直接将它们作为二进制文件写入数据库(我不是要上传表格)关于如何做到这一点的任何线索?谢谢编辑:这是我已经使用attachment-fugem编写的一些代码:http=Net::HTTP.new('awebsite',443)http.use_ssl=truehttp.verify_mode=OpenSSL::SSL::VERIFY_NONEhttp.start(){|http|req=Net::HTTP::Get.new("image.jpg")req.basic_authlogin,passwordrespon

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 /萨翁 : Having trouble with namespace for a soap request

我在更改正在构建的SOAPxml的命名空间时遇到问题。我不确定如何将“xmlns:env=”更改为“xmlns:soapenv=”,将“xmlns:tns=”更改为“xmlns:web=”我要构建的内容:100degreeCelsiusdegreeFahrenheit我目前得到的100degreeCelsiusdegreeFahrenheit我的代码:client=Savon.client(wsdl:"http://www.webservicex.net/ConvertTemperature.asmx?WSDL")message={temperature:'100',FromUnit:

ruby-on-rails - Rails 3.2 ActiveAdmin 'Collection is not a paginated scope.' 错误

我正在使用Rails3.2和ActiveAdmin0.4.4开发应用程序。我有一个名为Teaser的模型(/app/models/teaser.rb):classTeasertruemount_uploader:img,TeaserUploaderend然后我向其中添加了ActiveAdmin(/app/admin/teaser.rb):#encoding:UTF-8ActiveAdmin.registerTeaserdoformdo|f|f.inputs"Teaser"dof.input:name,:label=>'Текст'f.input:url,:label=>'Ссылка'

ruby-on-rails - rails : is Passenger Standalone suitable for production deployment?

问题标题几乎概括了它...我一直无法找到任何好的资源来概述使用PhusionPassengerStandalone进行Rails应用程序部署的优缺点。它与运行PassengerNginx或PassengerApache相比如何?.htaccess之类的东西是否继续按预期工作?任何见解将不胜感激!谢谢! 最佳答案 Standalone建立在Nginx之上。你可以直接将它连接到端口80,它的行为很像PhusionPassenger+Nginx:它可以非常快速地提供静态文件,它会根据流量自动启动和停止进程,它会在它们运行时自动重启进程崩溃

ruby-on-rails - Ruby:将数组传递给 starts_with?

我想检查我的url是否以某些字符串开头,以便随后将其保存到数据库中。字符串存储在一个数组中,由于starts_with?接受多个值,我想获取starts_with?中的所有数组值。array=["www.example.com/content1","www.example.com/content2","www.example.com/content3"]save_url=url.starts_with?()#hereIwanttoinsertallarrayvalues,buthow?ifsave_url#Iwanttocheckifsave_urlistruesomyentriesa

ruby-on-rails - rails/事件记录 : save changes to a model's associated collections

我是否必须保存对模型集合中单个项目的修改,或者是否有一种方法可以在我保存模型时调用以保存它们。#save似乎没有这样做。例如:irb>rental=#...#=>#irb>rental.dvd#=>#,sale_price:#>irb>rental.dvd.copies+=1#=>21irb>rental.save#=>trueirb>rental.dvd#=>#,sale_price:#>irb>Dvd.find_by_title('TheWomenofSummer')#=>#,sale_price:#>在上面的例子中,租赁的DVD副本似乎没有更新数据库中的副本(注意不同的副本数)。

ruby-on-rails - rails : why is calling to_a on a string not valid in a rake task?

我正在尝试解密一组用于数据库迁移的密码。我有一些旧的Rails代码(实际上是一个Runner脚本)可以很好地解密它们。但是将相同的代码放入Rake任务会导致任务失败,并显示...未定义的方法`to_a'for"secretkey":String...为什么在字符串上调用to_a在Rake任务中无效,但在Runner脚本中却完全有效?require'openssl'KEY='secretkey'namespace:importdotask:users=>:environmentdodefdecrypt_password(pw)cipher=OpenSSL::Cipher::Cipher.