草庐IT

USER_REQUIRED

全部标签

ruby - 在 Ruby 中实现 `call_user_func_array`

我怎样才能完成http://php.net/manual/en/function.call-user-func-array.php在ruby中?所以我可以这样做:classAppdeffoo(a,b)putsa+benddefbarargs=[1,2]App.send(:foo,args)#doesn'tworkApp.send(:foo,args[0],args[1])#doeswork,butdoesnotscaleendend 最佳答案 尝试分解数组App.send(:foo,*args)

ruby-on-rails - 致命 : Peer authentication failed for user "rails"

我正在尝试运行rakedb:create在DigitalOcean服务器上使用postgresql。但是,它返回错误Peerauthenticationfailedforuser"rails",引用config/database.yml登录凭据的存储位置奇怪的是,当我通过SSH登录服务器时,这些凭据以纯文本形式显示给我。我都试过了密码以纯文本形式显示给我,同样的事情发生了。环境在生产中,我必须手动强制执行,因为应用程序在启动时正在开发中并强制它在config/environments.rb中更改不工作。如果我不得不猜测,我可能会说环境中发生了一些有趣的事情,因为DigitalOcean

ruby-on-rails - rails 生成 rspec :install config/environments/development. rb:1:in `<top (required)>': 未定义方法 `configure'

首先,这是我的版本:Greg-Nowickis-MacBook-Pro:sample_appGreg_Nowicki$ruby-vruby2.0.0p451(2014-02-24revision45167)[x86_64-darwin13.1.0]Greg-Nowickis-MacBook-Pro:sample_appGreg_Nowicki$rails-vRails4.0.4我正在学习HartlRails教程并安装rspec进行测试。我已将gem'rspec-rails'添加到我的gemfile中,当我运行railsgeneraterspec:install时,这就是我得到的:Gre

ruby-on-rails - after_save 回调将 updated_by 列设置为 current_user

我想使用after_save回调将updated_by列设置为current_user。但是current_user在模型中不可用。我应该怎么做? 最佳答案 需要在controller中处理。首先在模型上执行保存,然后如果成功则更新记录字段。例子classMyController另一种选择(我更喜欢这个)是在您的模型中创建一个自定义方法来包装逻辑。例如classRecord 关于ruby-on-rails-after_save回调将updated_by列设置为current_user,我

ruby - Heroku,设计 : Getting 'NoMethodError (undefined method ` to_key' for :user:Symbol)'

我不知道它是什么时候发生的,但我收到了这个错误NoMethodError(undefinedmethod'to_key'for:user:Symbol)此行为仅发生在HerokuCedar堆栈上。我使用Devise(1.4.2)通过FacebookonRails3.1.0.rc6和ruby​​1.9.2-p290进行身份验证。它发生在sign_in_and_redirect(:user,authentication.user)行。这是我的方法:defcreateomniauth=request.env['omniauth.auth']authentication=Authenticat

ruby-on-rails - ruby + Mongoid : how to make a required field?

我使用Mongoid的githead版本(因为Rails4),我想制作一个字段必填文档:classMyClassincludeMongoid::Documentfield:name,type:String,required:true我有这个错误:Problem:Invalidoption:requiredprovidedforfield:name.Summary:Mongoidrequiresthatyouonlyprovidevalidoptionsoneachfielddefinitioninordertopreventun...我做错了什么? 最佳答案

ruby-on-rails - #<ProjectsController :0x007faead1853e0> 的未定义方法 `user_signed_in?'

我想用RubyonRails进行身份验证,每个用户都有自己的帐户。但是现在我得到了这个错误:undefinedmethoduser_signed_in?for#有人能帮帮我吗?代码如下:完整跟踪:app/controllers/projects_controller.rb:69:in`require_login'activesupport(3.2.3)lib/active_support/callbacks.rb:418:in`_run__2505248868868045404__process_action__114470166732456289__callbacks'actives

ruby-on-rails - rails : Omniauth - "The parameter app_id is required"

我正在按照这个railscast教程在我的rails项目上为facebook身份验证设置omniauth:http://railscasts.com/episodes/360-facebook-authentication?autoplay=true.我只用了4分钟,到目前为止我所做的就是捆绑gemomniauth-facebook并添加,omniauth.rbOmniAuth.config.logger=Rails.loggerRails.application.config.middleware.useOmniAuth::Builderdoprovider:facebook,ENV

ruby-on-rails - Rails : Before process_action callback :authenticate_user! 尚未定义

我正在创建一个包含设计的Rails应用程序。我正在尝试使用Ngrok将Twilio消息传递添加到我的站点,我使用了本教程:https://www.twilio.com/blog/2016/04/receive-and-reply-to-sms-in-rails.html我能够在控制台中打开Ngrok并获取他们为我的网址提供的网络ID。当我将url插入浏览器时,我不断收到此错误。我应该访问我自己的Rails本地应用程序。不知道怎么了。我在为ngrok制作的消息传递Controller中添加的内容:classMessagesController"reply"defreplymessage_

ruby - "HTTPI tried to user the httpi adapter"使用 Savon SOAP 库时出错

我正在使用Savon为SOAP服务编写一个Ruby接口(interface)。它似乎正在工作,但我在命令行上出现了几条DEBUG消息D,[2011-02-15T16:33:32.664620#4140]DEBUG--:HTTPI尝试使用httpclient适配器,但无法在LOAD_PATH中找到库。后退现在使用net_http适配器。D,[2011-02-15T16:33:32.820863#4140]DEBUG--:HTTPI使用net_http适配器执行HTTPPOST我不确定为什么会出现这些消息,或者它们的含义。有什么想法吗? 最佳答案