我添加了创建新的迁移:
class AddColumnsToDiscipline < ActiveRecord::Migration
def change
add_column :disciplines, :days, :integer, array: true
end
end
Run Code Online (Sandbox Code Playgroud)
然后我就进行了迁移。
在我的seed.rb文件中我添加了这个
t.disciplines.create(name: Company.name, days: [1, 2, 3])
Run Code Online (Sandbox Code Playgroud)
当我运行之后rake db:seed,当我运行我rails console所有创建的模型days属性时,它就具有nil值了。我错过了什么?
在 rails_admin 列表中,根据列在数据库中的排序方式显示模型的所有可用列:
但是,我希望列表页面中的顺序不同。我首先想要name表中的其他字段。
甚至有可能吗?rails_admin 的文档中没有提及它。
我有一个远程Ubuntu服务器VPS,我连接并通过结构执行命令.
我使用Windows PC连接到这个远程VPS,使用以下命令:
@task
def git_pull():
"""
"""
run("cd ~/{}/; git pull".format(env.repo_name))
Run Code Online (Sandbox Code Playgroud)
当我运行此命令时,它会让我写下我的Git的登录名和密码.
当我尝试输入它们时,它会像这样写:
(virtualenv) D:\path\to\project\fabfile>fab common.git_pull
[1.2.3.4] Executing task 'common.git_pull'
[1.2.3.4] run: cd ~/project/; git pull
[1.2.3.4] out: Username for 'https://git.example.com': u^@s^@e^@r^@
Run Code Online (Sandbox Code Playgroud)
正如您在我尝试编写时所看到的那样,将user其写为u^@s^@e^@r^@
它附加了这个奇怪的插入^@符号
为什么windows fabric附加了这些奇怪的^@符号?
是因为paramiko织物正在使用它?
我认为这种情况发生的原因是编码不同而且我使用了chcp命令,它仍然附加了这些额外的符号.
My Grape API接受json格式,我有接受JSON作为参数的方法:
desc 'JSON test'
params do
requires :json, type: JSON
end
post :json_test do
json = params[:json]
{result: json}
end
Run Code Online (Sandbox Code Playgroud)
当我通过邮递员发出请求时,参数是原始的application/json内容类型:
{
"json": {"test": "test"}
}
Run Code Online (Sandbox Code Playgroud)
当我发送这个时,我收到错误消息:
"json is invalid"
Run Code Online (Sandbox Code Playgroud)
但是,当我这样发送时:
{
"json": "{\"test\": \"test\"}"
}
Run Code Online (Sandbox Code Playgroud)
它显示了我正确的答案:
{
"result": {
"test": "test"
}
}
Run Code Online (Sandbox Code Playgroud)
为什么会这样?当我制作类型Hash第一个变体工作,但如果我想发送Array哈希/ jsons?我知道Grape不支持Array[Hash]类型.
在我的 firebase 仪表板中,我设置了multiple accounts for one email选项。
我的应用程序中有简单的电子邮件、Facebook 和 Google Plus 身份验证。
我在 LoginActivity 中像这样处理它们中的每一个:
谷歌加:
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
mAuth.signInWithCredential(credential)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
dialog.dismiss();
if (task.isSuccessful()) {
// Sign in success, update UI with the signed-in user's information
FirebaseUser user = mAuth.getCurrentUser();
proceed();
} else {
// If sign in fails, display a message to the user.
Toast.makeText(LoginActivity.this, task.getException().getMessage(),
Toast.LENGTH_SHORT).show();
}
// ... …Run Code Online (Sandbox Code Playgroud) android facebook google-api firebase firebase-authentication
我在本地启动了WSO2 API Manager.
我正在尝试使用httpsconnecttion 添加API端点.它向我展示了那种错误.
它显示了我的Invalid. unable to find valid certification path to requested target错误消息.
然后我下载了证书,这是cer来自网站的文件,在carbon页面我已经将证书导入到wso2carbon密钥库:
之后,我重新启动我的WSO2 API管理器并尝试测试此端点,它仍然会抛出该错误.
我错过了什么?
控制台显示那种错误:
[2017-06-12 21:12:18,362] ERROR - APIProviderHostObject Error occurred while connecting to backend : https://example.com, reason : sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1949) …Run Code Online (Sandbox Code Playgroud) 我已经通过Wiki上的此链接生成了自定义操作。我创建了从继承的类RailsAdmin::Config::Actions::Base。
我已经为此操作创建了视图 rails_admin_my_action/app/views/rails_admin/main/my_action.html.erb
当我们为您的控制器创建表单时,我们通常会使用form_for将用于我的控制器的表单并执行特定操作,但是我认为rails_admin还有其他事情,因为rails_admin使用他自己的控制器,该控制器由生成RailsAdmin::Config::Actions::Base。
如何为我的自定义rails_admin操作创建表单?
我问这个问题是因为没有关于此的适当文档。
我对自己的行为的看法是这样的:
<h3>Manage state of <%= @object.name %></h3>
Run Code Online (Sandbox Code Playgroud)
<div class="btn-group" data-toggle="buttons">
<% @object.state_events.each do |event| %>
<label class="btn bnt-lg btn-default">
<%= form.radio_button :state, event, autocomplete: 'off' %> <%= event %>
</label>
<% end %>
</div>
<br/>
<hr/>
<%= form.submit 'Change', class: 'btn btn-lg btn-primary' %>
Run Code Online (Sandbox Code Playgroud)
在lib/my_action.rb我刚才复制register_instance_option :controller的edit作用。
当我提交表格时。我ActiveModel::ForbiddenAttributesError出错了。
我想通过使用request模块来进行简单的POST HTTP请求:
var request = require("request");
var form = {form: {some: "form", attributes: "attrs"}}
request.post("https://example.com", form)
.on('response', function(response) {
if (response.statusCode === 200) {
console.log("DONE");
} else {
console.log("FAIL");
}
});
Run Code Online (Sandbox Code Playgroud)
当我启动此代码时,它引发以下错误消息:
Error: unable to verify the first certificate
at Error (native)
at TLSSocket.<anonymous> (_tls_wrap.js:1057:38)
at emitNone (events.js:67:13)
at TLSSocket.emit (events.js:166:7)
at TLSSocket._finishInit (_tls_wrap.js:596:8)
Run Code Online (Sandbox Code Playgroud)
我认为发生这种情况是因为url具有https,但我不知道如何解决此错误。
如何禁用检查证书?
我试图了解芹菜的工作原理
在tasks.py文件的Django应用程序中,我创建了一个任务:
@celery.shared_task(default_retry_delay=2 * 60, max_retries=2)
def my_task(param1, param2):
# There are some operations
Run Code Online (Sandbox Code Playgroud)
我通过使用以下代码来调用此任务:
my_task.delay(param1, param2)
Run Code Online (Sandbox Code Playgroud)
在这种my_task情况下,有一种情况应重新启动此任务,但要延迟一分钟
我发现任务有一些预计到达时间和倒计时,但它们的示例仅适用于apply_async
可以使用某种倒计时delay吗?
我有一个REST API,它只接受带有表单数据的POST请求.
我知道在Power Query中JSON请求是这样的:
let
url = "https://example.com",
body = "{ ""first_param"": ""AAAAA"", ""second_param"": ""BBBBBB""}",
Source = Json.Document(Web.Contents(url,[ Headers = [#"Content-Type"="application/json"], Content = Text.ToBinary(body) ] ))
in
Source
Run Code Online (Sandbox Code Playgroud)
如何发送表单数据?
ruby ×3
python ×2
rails-admin ×2
android ×1
celery ×1
cmd ×1
django ×1
excel ×1
fabric ×1
facebook ×1
firebase ×1
google-api ×1
javascript ×1
json ×1
node.js ×1
powerquery ×1
ruby-grape ×1
ssl ×1
windows ×1
wso2 ×1