给出一个简单的ID,如: 807811447862468608
如何将其嵌入我的页面?
我已经查看了StackOverflow上的其他问题,但它们需要整个推文HTML才能出现.我只是想保存对推文的引用,让小部件接受它.
如何验证Note模型的标签数量?我的模特目前:
# == Schema Information
#
# Table name: notes
#
# id :integer not null, primary key
# title :text
# body :text
# organization_id :integer
# created_at :datetime not null
# updated_at :datetime not null
# tags :string default([]), is an Array
#
# Note represents a saved Note that belongs to an organization.
class Note < ApplicationRecord
belongs_to :organization
validates :title, :body, presence: true
end
Run Code Online (Sandbox Code Playgroud)
tags 是数据库中的pg数组.
stack_html += "<div class='co-stack-layer-title'>Application and Data" +
"<div class='row'>" +
response['Application and Data'].forEach(generateStackItem) +
"</div>" +
"</div>";
stack_html += "<div class='co-stack-layer-title'>Business Tools" +
"<div class='row'>" +
response['Business Tools'].forEach(generateStackItem) +
"</div>" +
"</div>";
stack_html += "<div class='co-stack-layer-title'>DevOps" +
"<div class='row'>" +
response['DevOps'].forEach(generateStackItem) +
"</div>" +
"</div>";
stack_html += "<div class='co-stack-layer-title'>Utilities" +
"<div class='row'>" +
response['Utilities'].forEach(generateStackItem) +
"</div>" +
"</div>";
function generateStackItem(element, index, array) {
var stack_item_html = "";
stack_item_html += "<div class='co-service'>" +
"<a href='" + element['canonical_url'] + "' class='each-service hint …Run Code Online (Sandbox Code Playgroud) 我想尝试新的 phx.gen.auth 和 esbuild 系统。我知道 1.6.0-dev 尚未发布,但 Twitter 上人们正在谈论它有多好。
我似乎无法找到使用此未发布版本创建新应用程序的方法。
我正在构建一个简单的搜索功能,我想找到字符串字段中包含字符串的所有记录.
这是我尝试过的.
term = "Moby"
MyApp.Book
|> where([p], String.contains?(p, term))
|> order_by(desc: :inserted_at)
Run Code Online (Sandbox Code Playgroud)
这将返回以下书籍:
但我得到:
`String.contains?(p, term)` is not a valid query expression
Run Code Online (Sandbox Code Playgroud) 我有一个 Ecto.DateTime 我试图从中提取信息。
这工作正常:
{{y, m, d}, _} = Ecto.DateTime.to_erl(date)
"#{m}/#{d}/#{y}"
Run Code Online (Sandbox Code Playgroud)
我现在正在尝试获取小时/分钟/秒值:
{{y, m, d}, {h,m,s}} = Ecto.DateTime.to_erl(date)
"#{m}/#{d}/#{y}"
Run Code Online (Sandbox Code Playgroud)
但我收到这个错误
右侧值不匹配:{{2017, 5, 5}, {12, 0, 0}}
给定这个结构,我如何在这个深层嵌套的对象结构中找到具有给定id的对象.
const menuItems = [
{
id: 1,
imageUrl: "http://placehold.it/65x65",
display: "Shop Women",
link: "#",
type: "image",
nextItems: [
{
id: 10,
display: "?",
link: "#",
type: "menuitem"
},
{
id: 20,
display: "??",
link: "#",
type: "menuitem-withmore",
nextItems: [
{
id: 100,
display: "I'm inside one nest",
link: "#",
type: "menuitem"
}
]
},
{
id: 30,
display: "??",
link: "#",
type: "menuitem-withmore",
nextItems: []
},
{
id: 40,
display: "??",
link: "#",
type: "menuitem-withmore",
nextItems: []
},
{ …Run Code Online (Sandbox Code Playgroud) 我只是尝试使用 Elixir 运行特定格式的curl 命令。
$ curl -w "@config/curl-format.txt" -o /dev/null -s "http://wordpress.com/"
0.004, 0.017, 0.000, 0.017, 0.000, 0.029, 0.029
Run Code Online (Sandbox Code Playgroud)
直接从终端运行命令效果很好。
这就是我在 Elixir 中尝试做的事情:
args = ["-w config/curl-format.txt", "-o /dev/null", "-s", "http://wordpress.com"]
result = System.cmd("curl", args, [])
Run Code Online (Sandbox Code Playgroud)
但我得到:
{" config/curl-format.txt", 23}
Run Code Online (Sandbox Code Playgroud)
而且结果和上面不一样。
我的模型功能:
def admin_user
users.where('roles @> ARRAY[?]::varchar[]', ['admin']).first
end
Run Code Online (Sandbox Code Playgroud)
我的管理员配置:
config.model 'Team' do
list do
field :admin_user
end
end
Run Code Online (Sandbox Code Playgroud)
它显示如下:
我怎样才能让它链接到用户管理视图?
elixir ×4
javascript ×3
ecto ×2
object ×2
activeadmin ×1
arrays ×1
command ×1
curl ×1
datetime ×1
find ×1
foreach ×1
html ×1
json ×1
lodash ×1
model ×1
postgresql ×1
rails-admin ×1
ruby ×1
sql-like ×1
system ×1
twitter ×1
validation ×1