我想知道我们可以将图像转换为base64并将其保存在数据库中并在视图中访问它.
我搜索了谷歌和stackoverflow,所有这些都从中间开始编码或显示图像.
我需要知道如何转换图片网址/路径(假设我将图片存储在我的应用内,其网址存储在列中)
如何在保存之前将其编码为base64(我们应该首先转换为base64并保存在db?中).如何在视图中显示它
我想在葡萄实体文件中有多个类,这是文件夹结构app/api/proj/api/v2/entities/committees.rb
module PROJ::API::V2::Entities
class Committee < Grape::Entity
expose :id
expose :name, :full_name, :email, :tag, :parent_id
expose :country do |entity, option|
entity.parent.name if entity.parent.present?
end
# include Urls
private
def self.namespace_path
"committees"
end
end
class CommitteeWithSubcommittees < CommitteeBase
# include ProfilePhoto
expose :suboffices, with: 'PROJ::API::V2::Entities::CommitteeBase'
end
Run Code Online (Sandbox Code Playgroud)
在Grape API中
present @committees, with: PROJ::API::V2::Entities::Committee
Run Code Online (Sandbox Code Playgroud)
工作中.但如果我在场
present @committees, with: PROJ::API::V2::Entities::CommitteeList
Run Code Online (Sandbox Code Playgroud)
它不起作用.但是当我将它移动到一个名为committee_list.rb实体内部的新文件时,它会起作用.
我正在使用letrate gem并收到以下错误:
ArgumentError - wrong number of arguments (3 for 2):
lib/letsrate/lib/letsrate/model.rb:69:in `letsrate_rateable'
app/models/model_definition.rb:3:in `<class:ModelDefinition>'
app/models/model_definition.rb:1:in `<top (required)>'
Run Code Online (Sandbox Code Playgroud)
我试图将版本降级1.0.9为1.0.8,然后我将源复制到lib目录仍然我得到相同的错误.
我一直在关注gmaps4rails gem,我能够使用setinterval函数重新加载标记.我面临的问题是在每个间隔后地图恢复原状,即如果我放大它会恢复正常.
这是代码
success: (data, jqxhr, status) ->
console.log('data.bookings', data)
$('#multi_markers').removeClass('hidden')
$('.empty_booking_text').removeClass('hidden')
$('#sidebar_container').html('Please click any booking marker on the map')
markers_from_api = data.bookings
handler = Gmaps.build('Google')
settings = {
internal: {
id: 'multi_markers'
},
provider:{
styles: mapStyles
}
}
handler.buildMap settings, ->
markers = handler.addMarkers(markers_from_api)
_.each markers,(marker, j) ->
google.maps.event.addListener marker.serviceObject, 'click', (object) ->
console.log marker.serviceObject.position.lng()
render_marker_data markers_from_api[j].id
return
handler.bounds.extendWith markers
handler.fitMapToBounds()
setInterval () ->
$ -> update_marker_data(handler)
, 10000
Run Code Online (Sandbox Code Playgroud)
每10秒我更新一次标记
update_marker_data = (handler) ->
markers = []
$.ajax '/technician_locations/current_location', …Run Code Online (Sandbox Code Playgroud) 我正在使用rails 5和grape for api,我正在尝试为表格应用程序创建葡萄终点.
module PROJ::API::V2
class Applications < ::Grape::API
get '/' do
authorize! :read, Application
status 200
present Application.list(filter_params, current_user), with: Entities::ApplicationList, only_show: params[:only], person_base: true, current_ability: current_ability, user: current_user, nps_details: params[:nps_details]
end
end
end
Run Code Online (Sandbox Code Playgroud)
我正在获得未初始化的常量PROJ :: API :: V2 :: Applications :: Application.我尝试更改类名和文件名仍然发生相同的错误.
目前我像运行sidekiq
bundle exec sidekiq
Run Code Online (Sandbox Code Playgroud)
它将输出记录到log/sidekiq.log。但是我想为它运行的每个进程提供单独的文件。
例如,如果首先运行流程,sidekiq_1.log则应创建它。
我有一个无服务器项目,我正在尝试将 Dynamo DB 表导出到单个 csv 中,然后将其上传到 S3。
我检查的所有 npm 模块都导出单个表。有没有办法将多个表数据导出到一个 csv 中?
grape-api ×2
ruby ×2
base64 ×1
entity ×1
gmaps4rails ×1
google-maps ×1
image ×1
rating ×1
ruby-grape ×1
sidekiq ×1