草庐IT

submitted_at

全部标签

ruby - 如何使用 Nokogiri 的 xpath 和 at_xpath 方法

我正在学习如何使用Nokogiri,根据这段代码我遇到了一些问题:require'rubygems'require'mechanize'post_agent=WWW::Mechanize.newpost_page=post_agent.get('http://www.vbulletin.org/forum/showthread.php?t=230708')puts"\nabsolutepathwithtbodygivesnil"putspost_page.parser.xpath('/html/body/div/div/div/div/div/table/tbody/tr/td/div

ruby - 导轨 4 : column reference "updated_at" is ambiguous with Postgres

我正在尝试使用“updated_at”字段的日期时间范围查询数据库。前端在JSON数组中发送查询:["2015-09-0100:00:00","2015-10-0223:00:00"]在RailsController中,我使用以下方法将两个字符串解析为DateTime:start_date=DateTime.parse(params[:date_range_arr][0])end_date=DateTime.parse(params[:date_range_arr][1])#...@events=@events.where('updated_atBETWEEN?AND?,start_d

ruby-on-rails - 安装 active admin 时 activeadmin.git (at master) is not yet checked out 错误

Activeadmingem已添加到我的rails项目中,但每次我尝试安装railsgactive_admin:install时,我都会收到类似的错误git://github.com/activeadmin/activeadmin.git(atmaster)isnotyetcheckedout.Runbundleinstallfirst.我肯定在运行“railsgactive_admin:install”之前运行了bundle。运行“bundleshow”后,我看到我已将“*activeadmin(1.0.0.pre3f916d6)”添加到我的项目中,但不断收到此错误消息。我的gem文

ruby-on-rails - Rails 和 MQTT : Subscribe to topic in background at server startup?

我想在服务器启动时在我的Rails应用程序中订阅一个mqtt主题,并保持订阅始终处于事件状态和运行状态。我正在使用这个mqttgem进行mqtt通信:https://github.com/njh/ruby-mqtt这是我现在拥有的:在application.rb中:config.after_initializedomqttSub=BackgroundMQTT.newmqttSub.runend后台MQTT类:classMQTTSubscriberdefrunThread.newdoMQTT::Client.connect(:host=>'localhost',:port=>1883,)

ruby-on-rails - Rspec 的 instance_double 创建间歇性规范失败

我在使用instance_double时遇到间歇性测试失败。我有一个包含4个规范的文件。这是来源:require'rails_helper'describeSubmitPostdobefore(:each)do@post=instance_double('Post')allow(@post).toreceive(:submitted_at=)endcontext'onsuccess'dobefore(:each)doallow(@post).toreceive(:save).and_return(true)@result=SubmitPost.call(post:@post)endit

ruby - Rails+ActiveAdmin - 使用 ransacker 过滤会抛出错误 PG::SyntaxError: ERROR: syntax error at or near ","

我在RubyonRails4.1.4上有一个项目,使用来自git://github.com/activeadmin/activeadmin的activeadmin1.0.0.pre,pg0.17.1,PostgreSQL9.3在项目中我有这些模型:类用户has_one:账户类账户属于:用户有很多:project_accountshas_many:项目,:through=>:project_accounts类项目#该项目有一个bool属性'archive'has_many:project_accounts类ProjectAccount属于:帐户属于:项目我有一个任务是在索引页面上实现一个

ruby - 为什么在 IRB 中使用 Refinement 时得到 "main.using is permitted only at toplevel"?

我尝试在IRB(v0.9.6,Ruby2.3.0)中使用Refinement:moduleFoorefineObjectdodeffoo()"foo"endendendusingFoo#=>RuntimeError:main.usingispermittedonlyattoplevel这基本上是theexactsetupfromthedocumentation(这会导致相同的错误)。出了什么问题?我该如何解决这个问题? 最佳答案 这可能是IRb的错误或功能不当。众所周知,由于IRb的实现方式非常骇人听闻,因此它无法在所有极端情况下正

ruby - 错误 : Cookbook loaded at path(s) has invalid metadata

当我运行时::$vagrantprovision或:$vagrantup我有一个错误:nisevi@localhostprocessor(master):$vagrantprovisionUsingsshdeploykeyof:/home/nisevi/.ssh/id_rsa==>default:Chef12.0.3Omnibuspackageisalreadyinstalled.==>default:Runningprovisioner:shell...default:Running:inlinescript==>default:W==>default::==>default:Dup

ruby-on-rails - 将 span 放入 f.submit

这可能很简单,但似乎无法正常工作。我有以下提交按钮我想在按钮中放置一个icomoon图像但是我如何在按钮中获取span类..?谢谢 最佳答案 使用button_tag并以这种方式将跨度放在按钮中SendMessage 关于ruby-on-rails-将span放入f.submit,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/22159698/

ruby-on-rails - 在不使用 `at_exit` 的情况下,如何确保操作在 Rails 退出之前运行?

我有一个操作需要在我的Rails应用程序终止之前在我的Rails应用程序中执行。我可以在Rails中为此使用一个钩子(Hook)吗?我猜类似于at_exit的东西。 最佳答案 Ruby本身支持两个钩子(Hook),BEGIN和END,它们在脚本开始时运行,并在解释器停止运行时运行。有关详细信息,请参阅“WhatdoesRuby'sBEGINdo?”。BEGIN文档说:Designates,viacodeblock,codetobeexecutedunconditionallybeforesequentialexecutionofth