我正在使用ruby 守护进程宝石.想知道如何为停止动作添加一些额外的步骤?希望我能检测到停止被调用,并添加一些额外的代码.谁知道我怎么能做到这一点?
我有一张看起来像这样的桌子.
<table>
<thead>
<tr>
<th>Foo</th>
<th>Bar</th>
</tr>
</thead>
<tbody>
<tr class="data">
<td>Info here</th>
<td><a href"/url_here" class="edit">Edit</a></td>
</tr>
<tr class="data">
<td>More here</th>
<td><a href"/url_here" class="edit">Edit</a></td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
我想在鼠标悬停在其中的任何行上时显示编辑链接.我尝试了一些方法,但仍然遇到同样的问题.假设我只是想错了方法.
这就是我现在拥有的.
$('a[class*=edit]').hide();
$('tr[class*=data]').bind("mouseover", function(e) {
$(e.target).closest('a[class*=edit]').addClass("selected");
$('a[class*=selected]:first').show();
}).mouseout(function() {
$('a[class*=selected]').hide();
$('a[class*=edit]').removeClass("selected");
})
Run Code Online (Sandbox Code Playgroud)
现有代码的问题是它不会添加所选类,除非您将鼠标悬停在编辑链接上.就像我上面提到的那样,当你将鼠标悬停在那一行的任何地方时,我需要它来添加所选的类.我也只希望它显示该特定行的编辑链接.
任何帮助都会非常感激我的头发拉了几个小时,我知道这可能是一些愚蠢的事情.谢谢!
我有一个测试TypeError: no impliciit conversion of String into Array,当它命中我的代码的特定部分时返回。如果我在rspec之外运行代码,则它运行得很好,所以我不确定为什么会这样。
require 'spec_helper'
require 'digital_ocean_size_list'
describe Chef::Knife::DigitalOceanSizeList do
subject { Chef::Knife::DigitalOceanSizeList.new }
let(:access_token) { 'FAKE_ACCESS_TOKEN' }
before :each do
Chef::Knife::DigitalOceanSizeList.load_deps
Chef::Config['knife']['digital_ocean_access_token'] = access_token
allow(subject).to receive(:puts)
end
describe "#run" do
it "should validate the Digital Ocean config keys exist" do
expect(subject).to receive(:validate!)
subject.run
end
....
Run Code Online (Sandbox Code Playgroud)
正在测试以下代码
require 'chef/knife/digital_ocean_base'
class Chef
class Knife
class DigitalOceanSizeList < Knife
include Knife::DigitalOceanBase
banner 'knife digital_ocean size list (options)'
def run
$stdout.sync = true
validate!
size_list = …Run Code Online (Sandbox Code Playgroud) 我有一个包含以下代码的数据库包.
package database
import (
"log"
"github.com/jinzhu/gorm"
// required by gorm
_ "github.com/mattn/go-sqlite3"
)
type Podcast struct {
ID int `sql:"index"`
Title string
RssURL string `sql:"unique_index"`
Paused bool
Episodes []Episode
}
type Episode struct {
ID int `sql:"index"`
PodcastID int
Title string
EnclosureURL string `sql:"unique_index"`
Downloaded bool
GUID string `sql:"unique_index"`
PubDate string
}
func DBSession() (db gorm.DB) {
sqliteSession, err := gorm.Open("sqlite3", cache.db)
if err != nil {
log.Fatal(err)
}
return sqliteSession
}
Run Code Online (Sandbox Code Playgroud)
接下来是一堆方法,所有方法都以下面的代码开头.
FindSomethingByID(id int) {
db := DBSession() …Run Code Online (Sandbox Code Playgroud)