我正在使用helpscoutruby gem并尝试检查请求限制何时低于一定数量(即剩余2个请求)并在剩余时间间隔内休眠以允许重置速率限制.
有没有办法在发出请求时从API访问响应头? https://developer.helpscout.com/help-desk-api/#basic-rate-limiting
X-RateLimit-Interval-* Length of the rate limiting interval in seconds
X-RateLimit-Limit-* Maximum number of requests per interval
X-RateLimit-Remaining-* Number of requests remaining in the current rate limit interval
Run Code Online (Sandbox Code Playgroud)
内部通信(https://developers.intercom.com/reference#rate-limiting)允许您检查rate_limit_details并返回标题,但我找不到任何帮助Scout的内容或了解如何访问它们.
intercom.rate_limit_details
#=> {:limit=>180, :remaining=>179, :reset_at=>2014-10-07 14:58:00 +0100}
Run Code Online (Sandbox Code Playgroud) 我希望使用新的 Rails 5.2 ActiveStorage 功能将文件上传添加到 Card 模型(包括单个和多个文件)。我在 Rails 中更强大,并且正在使用 Vue.js 来解决这个问题 - 以前我会使用 Paperclip 来处理这个问题。但是,我已经config/storage.yml为 ActiveStorage设置了文件和必要的迁移。我还设置了 Card 上的关联并将其更新CardController为 permit files: []。
card.vue我创建的组件目前运行良好;卡片可以有标题和描述,并且描述可以更新。这些记录会保留到数据库中。我的问题是弄清楚如何将文件上传绑定到卡,以及在保存时上传多个文件所需的逻辑。
目前我正在使用<input name="files" type="file" data-direct-upload-url="/rails/active_storage/direct_uploads" direct_upload="true" />在卡片中创建输入字段。但是,从我的本地机器选择一个 PDF 图像并单击保存后,日志显示没有任何反应[关于在 active_storage_attachments 中插入新行或创建 blob]。如何扩展保存方法以接受文件?
卡
class Card < ApplicationRecord
has_many_attached :files
end
Run Code Online (Sandbox Code Playgroud)
卡控制器
class CardsController < ApplicationController
private
def card_params
params.require(:card).permit(:list_id, :title, :position, :description, files: [])
end
end
Run Code Online (Sandbox Code Playgroud)
卡.vue
<template>
<div>
<div @click="editing=true" class="card card-body">
<h4>
{{card.title}}
</h4>
</div>
<div v-if="editing" class="modal-backdrop show"></div> …Run Code Online (Sandbox Code Playgroud) 我正在使用 Heroku 的 Scheduler 插件以预定的时间间隔在我的应用程序中运行作业,就像传统服务器环境中的 cron 一样。这些任务相当琐碎,因为它们只是将一个 sidekiq 工人排队。但是,正如您在下面的照片中看到的,由于:update_job_posts某种原因无法在 4:30UTC 运行。
我不能以这种方式将这两项工作结合起来,还是需要单独运行?
如果我通过heroku run它运行任务。heroku run用于执行您的作业,因此您可以放心,如果它与 heroku run 一起工作,它将在调度程序中工作。
$ heroku run rake scheduler:update_job_posts
Running rake scheduler:update_job_posts on ? agile-temple-76502... up, run.6604 (Free)
Updating Job feed...
I, [2018-06-06T04:40:50.341411 #4] INFO -- : [ActiveJob] Enqueued JobFeedImportJob (Job ID: e3b9a0ed-aacb-45af-84f9-ef02acfeb85e) to Sidekiq(default)
I, [2018-06-06T04:40:50.344400 #4] INFO -- : [ActiveJob] Enqueued RemoteFeedImportJob (Job ID: b965853d-adb3-46ee-b48d-f19306ce9d2a) to Sidekiq(default)
done.
Run Code Online (Sandbox Code Playgroud)
此外,heroku logs --tail显示正在运行的其他任务:
heroku[scheduler.5009]: Starting process …Run Code Online (Sandbox Code Playgroud) 设想 :
card-vat-fee到容器底部时遇到了困难。尝试案例:
min-height: 320px;在card-vat-fee类上设置 a它将使 div 与底部对齐,但这不是一个响应式解决方案,我觉得有一种更好的方法可以使用flex属性。此外,将card-vat-feediv设置为 flex-grow flex: 1 1 auto, 会产生不理想的解决方案。代码 :
<div class='pricing__tier'>
<div class='uni-card-header'>
</div>
<div class='uni-card-body'>
<div class='uni-row-on'>
</div>
<div class='uni-row-off'>
</div>
<div class='uni-row-on card-vat-fee'>
<div class='vat-fee-text'>
Credit card fees and VAT apply. See below for details.
</div>
</div>
</div>
</div>
<style>
.pricing__tier {
padding: 0;
text-align: …Run Code Online (Sandbox Code Playgroud) 我正在尝试将一些业务逻辑从一个控制器中移出,StoreController并移到一个新的Store::CreateService服务对象中。最近了解了服务,似乎并没有很多实现这些服务的既定模式。我在尝试调用受保护的方法时遇到错误。我显然可以将逻辑从那些受保护的方法直接移到其中,execute但是我的理解是,这对Rails应该没问题。
undefined local variable or method `find_and_set_account_id' for #<Store::CreateService:0x00007f832f8928f8>
Run Code Online (Sandbox Code Playgroud)
这是服务对象
module Store
class CreateService < BaseService
def initialize(user, params)
@current_user, @params = user, params.dup
end
def execute
@store = Store.new(params)
@store.creator = current_user
find_and_set_account_id
if @store.save
# Make sure that the user is allowed to use the specified visibility level
@store.members.create(
role: "owner",
user: current_user
)
end
after_create_actions if @store.persisted?
@store
end
end
protected
def after_create_actions
event_service.create_store(@store, current_user)
end
def find_and_set_account_id
loop do
@store.account_id …Run Code Online (Sandbox Code Playgroud)