我正在尝试调试运行bundle exec rake 任务时出现的一些错误。
ArgumentError: You tried to define an enum named "catalogue" on the model "CollectionContext", but this will generate a instance method "museum?", which is already defined by another enum.
Run Code Online (Sandbox Code Playgroud)
SO 有很多与此问题相关的问题,但所有问题似乎都归结为同一模型中不同枚举使用相同的值,这可以通过使用 _suffix 或 _prefix 来解决。
这是 Rails 中枚举用法的精彩解释https://naturally.com/blog/ruby-on-rails-enum
就我而言,我在模型中看不到重复项。如何进一步调试错误?
class CollectionContext < ActiveRecord::Base
include Authority::Abilities
self.authorizer_name = 'ManagedContentAuthorizer'
has_many :context_sets, inverse_of: :collection_context
has_many :museum_collections, through: :context_sets,
source: :contextable,
source_type: 'MuseumCollection'
enum catalogue: %i[museum archive library]
enum vocabulary: {category: 10,
collection: 20,
concept: 30,
event: 40, …Run Code Online (Sandbox Code Playgroud) 我有一个脚本,用于将单个谷歌工作表保存为给定文件夹中的 pdf 文档。
由于工作表的内容是动态的,有时底部有大量空网格行,因此我提供了一种在导出文件之前隐藏没有内容的行的方法。
直到最近,这一直按要求工作。现在该函数隐藏了行,但创建的文件将行显示为未隐藏。
不知道这是否是由于最近对 google sheet api 的更改造成的,我可以做些什么来恢复旧功能?
这是我以前工作的代码块:
// API function for saving a single sheet without hiding sheets
// *******************************************************************************
function singleSheetAPIExport(){
// Get active spreadsheet URL
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheetName = 'Example';
var main = ss.getSheetByName(sheetName)
var folderID = '1wsxxxxxxblahblah' // Google Drive Folder ID
Logger.log('maxrows: ' + main.getMaxRows());
Logger.log('last row: ' + main.getLastRow());
// Base URL
var url = "https://docs.google.com/spreadsheets/d/SS_ID/export?".replace("SS_ID", ss.getId());
/* Specify PDF export parameters
From: https://code.google.com/p/google-apps-script-issues/issues/detail?id=3579
*/
var url_ext = …Run Code Online (Sandbox Code Playgroud) 我正在尝试构建一个 URL 字符串,它采用 BASE_PATH 和 fieldname 字符串以匹配我的 API 路由。不幸的是,我使用的外部数据库在字段名称中包含空格。
我的 api 路由是这样的:localhost/api/data/fieldname
我的提取请求如下所示:
const BASE_PATH = 'http://localhost:8082/api/data/'
componentDidUpdate() {
let URL = `${BASE_PATH}${this.props.fieldName}`
fetch(URL)
.then(response => response.json())
.then(data => this.populateData(data))
.catch(error => error);
}
Run Code Online (Sandbox Code Playgroud)
这在 fieldname = 教育时效果很好,但当 fieldname = 婚姻状况时效果不佳
当我将字段名用反引号包裹时,获取请求有效,例如。`marital status` 但我无法理解如何修改 URL 构建以在 ${this.props.fieldName} 周围放置反引号,因为我已经在字符串插值中使用了反引号。