草庐IT

CG_CONTEXT_SHOW_BACKTRACE

全部标签

ruby-on-rails - 每当 gem : I set :output but the logfile doesn't show up where I'd expect it to

在我的schedule.rb文件中,我有以下几行:set:output,'/log/cron_log.log'every5.minutesdocommand'echo"hello"'end我按照这个问题Rails,usingwhenevergemindevelopment中的建议运行了whenever-w,并且我假设cronfile已编写并正在运行。(我也尝试重新启动Rails服务器。)当我运行$crontab-l时,我看到以下内容:0,5,10,15,20,25,30,35,40,45,50,55****/bin/bash-l-c'echo"hello">>/log/cron_log

ruby - 使用 cucumber/aruba/timecop : How to inject the context 测试命令行应用程序

以下场景几乎概括了我的问题:Scenario:problemswithsubprocessesGiventhedateis01/01/201210:31WhenIrun`ruby-e"putsTime.now"`Thentheoutputshouldcontain"10:31"它归结为当我运行ruby​​-e"putsTime.now"时启动一个子进程,从而使我所有的Timecop.freezestub无效,因为他们只在主要过程中工作。我需要以某种方式将当前上下文“注入(inject)”到运行的命令中,但我似乎无法想出任何东西。我在这里尝试不可能的事情吗?步骤:require'time

ruby-on-rails - 事件管理员 : Can't access show/edit pages

我在使用ActiveAdmin时遇到问题。以下是版本:ruby'2.2.1'rails'4.2.0'activeadmin:1.0.0.pre1arbre:1.0.3(提到这个是因为它似乎与我的问题有某种联系)我们升级到rails4.2并且还必须升级activeadmin(从0.5开始)。经过几次调整(尤其是授权系统)之后,一切似乎都很好,除了一个大问题:我只能访问索引页面。当转到具有ID的页面时(例如:“http://localhost:3000/admin/companies/2968”),我收到此错误:没有路由匹配{:action=>"edit",:controller=>"ad

ruby-on-rails - 设计注销错误 - 找不到 UsersController 的操作 'show'

设计生成了以下代码以将用户注销:并且在执行rakeroutes时出现路由destroy_user_sessionDELETE/users/sign_out(.:format){:action=>"destroy",:controller=>"devise/sessions"}但是我收到一条错误消息:Theaction'show'couldnotbefoundforUsersController有什么想法吗? 最佳答案 路径是正确的,但如果你仔细观察,你会发现它不是GET请求而是DELETE请求,所以传递方法::delete%>编辑:

ruby-on-rails - rails 引擎 : rake routes show its routes but on rspec execution "No route matches" is thrown

我正在尝试测试我的应用程序正在使用的引擎内部的Controller。规范不在引擎中,而是在应用程序本身中(我试图在引擎中进行测试,但也遇到了问题)。我的引擎有以下routes.rb:Revision::Engine.routes.drawdoresources:steps,only:[]docollection{get:first}endend引擎正常挂载在应用routes.rb上:mountRevision::Engine=>"revision"当我运行rakeroutes时,在最后一行我得到:RoutesforRevision::Engine:first_stepsGET/step

ruby - 在 Rails 中覆盖 "show"资源路由

resources:some_resource即有路由/some_resource/:id事实上,:idforsome_resource会一直保存在session中,所以我想重写路径/some_resource/:id使用/some_resource/my。或者我想用/some_resource/覆盖它并删除路径GET/some_resource/以进行索引操作。我怎样才能达到这两个目标? 最佳答案 在你的routes.rb中放置:get"some_resource"=>"some_resource#show"行前resources

ruby - 如何避免 RSpec 中的 "Useless use of == in void context"?

在RSpec中,如果我有警告并且有x.should==42another_line_of_code然后我得到一个关于的警告warning:uselessuseof==invoidcontext还有什么我可以做的吗关闭警告将其更改为bitbucket=(x.should==42) 最佳答案 使用:x.shouldeq(42)或者:x.shouldbe==42或者移动x.should==42使其成为itblock中的最后一行。对于那些思考但是为什么?的人我完全是Ruby的菜鸟,但这是我的理解:警告来自Ruby,因为像x.should==

ruby - Pry Error : Cannot find local context. 您是否使用了 `binding.pry`?

为什么我会收到此pry动错误?[36]pry(main)>s="pry"Error:Cannotfindlocalcontext.Didyouuse`binding.pry`?在此截屏视频中运行良好http://pryrepl.org/ 最佳答案 似乎s、c和n是pry-navgem上的保留命令,发现here,这可以帮助您逐步完成绑定(bind)。Pry.commands.alias_command'c','continue'Pry.commands.alias_command's','step'Pry.commands.alias

ruby-on-rails - rails : how to show user's "last seen at" time?

我正在使用存储current_sign_in_at和last_sign_in_at日期时间的设备。但是假设用户在一个月前登录但最后一次查看页面是在5分钟前?有什么方法可以显示(“5分钟前用户最后一次出现”)。 最佳答案 这个怎么样:创建迁移以向用户添加新字段以存储用户最后一次出现的日期和时间:railsgmigrationadd_last_seen_at_to_userslast_seen_at:datetime向您的应用程序Controller添加一个操作前回调:before_action:set_last_seen_at,if:

ruby-on-rails - 为什么 Rspec 说 "Failure/Error: Unable to find matching line from backtrace"?

我在这里学习Rails教程:http://railstutorial.org/chapters/filling-in-the-layout#top当我运行“rspecspec/”时,我得到一堆如下所示的错误:1)LayoutLinksshouldhaveaHomepageat'/'Failure/Error:Unabletofindmatchinglinefrombacktracestackleveltoodeep#C:/Ruby19/lib/ruby/1.9.1/forwardable.rb:1852)LayoutLinksshouldhaveaContactpageat'/cont