所以当我尝试从firebase获取数据时,我得到了这个
Invalid argument '{"-KCO4lKzEJPRq0QgkfHO":{"description":"teste","id":1457488598401,"resourceUrl":"tete","title":"test2"}}' for pipe 'AsyncPipe' in [listItems | async in ArcListComponent@2:10]
Run Code Online (Sandbox Code Playgroud)
ArcListComponent
import { Component, OnInit } from "angular2/core";
import { FirebaseService } from "../shared/firebase.service";
import { ArcItem } from "./arc-item.model";
@Component({
selector: "arc-list",
template: `
<ul class="arc-list">
<li *ngFor="#item of listItems | async " class="arc-item">
<h3>{{ item.name}}</h3><a [href]="item.resourceUrl" target="_blank" class="btn btn-success pull-right"><span>Go</span></a>
<hr>
<blockquote>{{ item.description }}</blockquote>
<hr>
</li>
</ul>
`
})
export class ArcListComponent implements OnInit {
listItems: string;
constructor(private _firebaseService: FirebaseService) {}
ngOnInit(): any {
this._firebaseService.getResources().subscribe( …
Run Code Online (Sandbox Code Playgroud) 我正在使用Geocoder宝石,但最近它似乎不起作用.
我收到此错误:
Geocoding API not responding fast enough (use Geocoder.configure(:timeout => ...) to set limit).
Run Code Online (Sandbox Code Playgroud)
我的application_controller.rb是:
before_filter :lookup_ip_location
private
def lookup_ip_location
if Rails.env.development?
prr = Geocoder.search(request.remote_ip).first
p "this is #{prr.inspect}"
else
request.location
end
end
Run Code Online (Sandbox Code Playgroud)
这是development.rb:
# test geocoder gem locally
class ActionDispatch::Request
def remote_ip
"71.212.123.5" # ipd home (Denver,CO or Renton,WA)
# "208.87.35.103" # websiteuk.com -- Nassau, Bahamas
# "50.78.167.161" # HOL Seattle, WA
end
end
Run Code Online (Sandbox Code Playgroud)
我正在从development.rb加载一个IP地址,以检查地理编码器是否在本地工作,但事实并非如此.我收到了上述错误.
此外,打印时prr
我没有.
我还添加了一个geocoder.rb初始化程序,将超时时间提高到15秒,但即使在浏览器加载页面15秒后,我仍然收到相同的消息.
它坏了吗?我应该使用另一颗宝石吗?如果是的话,你有什么建议吗?
因此,我有兴趣编写一种方法,当我单击导出按钮时,db中的某些数据将导出为JSON数据.
我怎样才能做到这一点?
程序就是这样
get data from db -> convert to json -> write to file -> save file to computer.
Run Code Online (Sandbox Code Playgroud)
谢谢
我正在尝试制作类似地铁的菜单,当用户将鼠标悬停在每个磁贴上时,我希望它显示一个盒子阴影.现在我开始工作了,但我读到最好在::after
伪元素上使用它更加平滑,但它似乎不起作用.这是jsFiddle.
p.tile {
text-align: center;
padding: 5rem;
background: #58588E;
color: white;
margin: 2rem;
box-sizing: border-box;
}
p.tile::after {
content: "";
box-shadow: 3px 5px 20px -1px rgba(0, 0, 0, 0.8);
opacity: 0;
transition: opacity 0.3s ease-in-out;
}
p.tile:hover::after {
opacity: 1;
}
Run Code Online (Sandbox Code Playgroud)
<a href="#" class="tile-link">
<p class="tile">My Progress</p>
</a>
Run Code Online (Sandbox Code Playgroud)
嘿伙计们,我试图显示服务器时间,但它显示的是当地时间。是否可以将服务器时区设置为加拿大之类的时区?
我试过这个application.rb
config.time_zone = 'Central Time (US & Canada)'
但当我使用Time.now
它时,它显示当地时间。
将不胜感激您的帮助。
ruby ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.2 ruby-on-rails-4
我想要实现的是在匹配下面的 if 条件后启用提交按钮,但在满足条件后似乎没有启用按钮。
<button [disabled]="!isFullfilled(m.value, n.value)" type="submit" class="ui button">Submit</button>
isFullfilled(m: number, n: number) {
if (
m === this.restrict_arr.length
&& m === this.xinitial_arr.length
&& m === this.lift_arr.length
&& n === this.param_arr.length
&& n === this.system_arr.length
) {
return true;
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
这是一个完整的示例plunker
我无法在 has_one 关系中只保留一条记录
例子
类别和问题
一个问题属于_一个类别,一个类别有_一个问题
实际上,在我正在构建的系统中看到,即使存在 has_one 关系,也会出现我有多个属于一个类别的问题的情况。
has_one 关系不应该将它们限制为只有一条记录吗?如果没有,那么我如何确保我始终保留一份记录?
编辑
请注意,问题模型对类别 ID 有唯一性规则,但我仍然发现多条记录指向同一类别 ID 的情况。
这怎么可能?
编辑 2
模型概述
class Event < ApplicationRecord
has_one :travel_time, :inverse_of => :event, dependent: :destroy
end
class TravelTime < ApplicationRecord
belongs_to :event, :inverse_of => :travel_time
validates_uniqueness_of :event_id, allow_nil: true
end
Run Code Online (Sandbox Code Playgroud)
编辑 3
在方法的事件模型中使用,以节省出行时间记录
def store_travel_times(body)
travel_times = self.build_travel_time
# get travel times
...
if !travel_times.save
logger.error "..."
end
end
Run Code Online (Sandbox Code Playgroud)
用于查找多条记录的查询
2017-05-04T13:39:15.277063 #50567] DEBUG …
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个博客。
到目前为止,我已经建立了一个名为Blog的名称空间,并以嵌套路由的形式发布了帖子
namespace :blog do
get '', to: 'welcome#index', as: '/'
resources :posts
end
Run Code Online (Sandbox Code Playgroud)
我的问题是,当用户要查看特定帖子时,如何创建HTML并将其保存在数据库中并进行呈现?
换句话说,如何创建,保存和呈现结构化内容?
我试图打开一些文本文件读取它们并从这些文件中获取az的所有字符,并使用这些字符进行更多处理.
但我得到了错误 ValueError: too many values to unpack
这是我的脚本的开始,它在这个代码块的注释行,我得到错误
for line in sys.stdin:
if ":" in line:
filename, line = line.strip().split(':') # this line gives error
Run Code Online (Sandbox Code Playgroud)
看起来它与拆分有关.我这样做的原因是因为我想要提取文件名并在stdin读取文件之前在其他地方读取,其格式
filename.txt: Start of the first line inside the text file
我也在一个文本文件上试过这个并且它工作但是现在我尝试完整批次我得到了这个
我这样从控制台调用它
grep -r '' susp-text | ./mapper.py | sort | ./suspicious_reducer.py
错误发生在第一个脚本上 mapper.py
更大的脚本图片
#!/usr/bin/env python
import sys
import re
# regular expressions
pattern = re.compile("[a-zA-Z]*",
re.MULTILINE | re.DOTALL | re.IGNORECASE)
a_to_f_pattern = re.compile("[a-fA-F]", re.IGNORECASE)
g_to_l_pattern = re.compile("[g-lG-L]", re.IGNORECASE)
m_to_r_pattern = re.compile("[m-rM-R]", …
Run Code Online (Sandbox Code Playgroud) 我正在尝试设置日期格式,但是从我检查过的文档和其他网站上没有提到如何制作这种格式
2 次 2017年一月
Date.tomorrow.strftime("%e %B %Y")
Run Code Online (Sandbox Code Playgroud)
会给
2017年1月28日
我怎么能做到
2017年1月28日?
可能吗?
ruby ×4
angular ×2
javascript ×2
activerecord ×1
css ×1
css3 ×1
firebase ×1
html ×1
json ×1
python ×1
typescript ×1