My Rails cron job:
every 3.hours do
runner "MyModel.some_process"
rake "my:rake:task"
command "/usr/bin/my_great_command"
end
我只想在MyModel中的属性设置为true时触发,并在设置为false时停止。
答案 0 :(得分:0)
对于MyModel中的属性(例如可用性)设置为true时触发,如果设置为false则停止,您需要在<?php
$api = 'AIzaSyB2__dPng5IGT9Nlca0UT7FxN459mrITmo';
$book_api = file_get_contents('https://www.googleapis.com/books/v1/volumes?q=fift+shades+of+grey&key='.$api);
$book = json_decode($book_api);
$meta_data = $book->items;
?>
<html>
<head>
<title>Exampe API Google Book</title>
</head>
<body>
<?php
for($i = 0; $i < count($meta_data); $i++)
{
$title = $meta_data[$i]->volumeInfo->title;
$author = $meta_data[$i]->volumeInfo->authors;
$desc = $meta_data[$i]->volumeInfo->description;
$cat = @$meta_data[$i]->volumeInfo->categories;
$pages = @$meta_data[$i]->volumeInfo->pageCount;
$thumb = $meta_data[$i]->volumeInfo->imageLinks->thumbnail;
echo "<h1>$title</h1><br/>";
echo "<p><img src=\"$thumb\" style=\"float:left; padding: 10px;\">$desc</p><br clear=\"all\" /><hr />";
}
?>
</body>
</html>
中创建一个方法 -
MyModel