随着即将于10月1日在Facebook上进行SSL迁移,所有应用都必须支持通过HTTPS进行连接,因此您需要SSL证书.
我使用以下命令在当前应用程序目录中创建了一个新的 Heroku 应用程序Heroku create并运行:
MyMac:bodb pawel$ git push heroku master
Counting objects: 359, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (291/291), done.
Writing objects: 100% (359/359), 13.83 MiB | 2 KiB/s, done.
Total 359 (delta 40), reused 0 (delta 0)
! Heroku push rejected due to an unrecognized error.
! We've been notified, see http://support.heroku.com if the problem persists.
To git@heroku.com:myproject.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push …Run Code Online (Sandbox Code Playgroud) 我有一个应用程序,它独家使用Facebook作为身份验证提供程序,并正确设置生产模式的回调.为了这个工作,你提供一个网站的URL和回调网站域名您的Facebook应用程序,并在我的情况下,它http://appname.heroku.com和appname.heroku.com分别.
问题是我的控制器设置为仅允许经过身份验证的会话,因此我无法在开发模式下查看我的应用程序,因为Facebook应用程序的域显然尚未设置为localhost.
如何解决这个问题而不必在Facebook的设置中更改它?
我有一个样式表,application.css定义layouts/application.html.erb如下:
<%= stylesheet_link_tag "application" %>
Run Code Online (Sandbox Code Playgroud)
但是,网站的一部分视图将使用完全不同的样式表,dashboard.css我在其中定义index.html.erb:
<head>
<title>My title</title>
<%= stylesheet_link_tag "dashboard" %>
..
Run Code Online (Sandbox Code Playgroud)
除非我删除应用程序布局文件中的stylesheet_link_tag,否则会出现使仪表板视图怪异的冲突.如果我将应用程序布局样式表标记移动到_header.html.erb部分,该部分使用非仪表板部分中的每个视图呈现,如下所示,则它不起作用.我怎么称呼他们?
<%= stylesheet_link_tag "application" %>
<header>
<div id="headercontainer">
..
Run Code Online (Sandbox Code Playgroud) 我有一个父和子组件对,让我坚持数据绑定.
顶级组件将呈现一个新Question组件:
<Question updateScore={this.updateScore} />
Run Code Online (Sandbox Code Playgroud)
该updateScore方法将仅使用数值更新哈希.那不是太重要.问题组件非常简单:
var Question = React.createClass({
getInitialState: function () {
return { options: blahBlahBlah };
},
updateScore: function(optionLabel) {
this.props.updateScore(optionLabel);
},
render: function() {
var optionList = this.state.options.map(function(option) {
return (
<QuestionItem optionLabel={option.optionLabel} description={option.description}
updateScore={this.updateScore} key={option.key} />
);
}.bind(this));
return (
<ul>
{optionList}
</ul>
);
}
});
Run Code Online (Sandbox Code Playgroud)
问题项组件甚至更简单:
var QuestionItem = React.createClass({
render: function() {
return (
<li onClick={this.props.updateScore.bind(this, this.props.optionLabel)}>
{this.props.description}
</li>
);
}
});
Run Code Online (Sandbox Code Playgroud)
问题是当前的实现,控制台吐出这个错误:
"Warning: bind(): React component methods may …Run Code Online (Sandbox Code Playgroud) 在此示例中,当我尝试在componentDidUpdate生命周期回调期间更新状态时,出现too much recursion错误.我应该如何更新州?
import React from 'react';
class NotesContainer extends React.Component {
constructor(props) {
super(props);
this.state = { listOfShoppingItems: [] };
}
componentDidUpdate(nextProps, nextState) {
let newShoppingItems = this.calculateShoppingItems();
this.setState({ listOfShoppingItems: newShoppingItems });
}
calculateShoppingItems() {
let shoppingItemsCart = []
if (this.props.milk < 3) {
let value = "Buy some milk";
shoppingItemsCart.push(value);
}
if (this.props.bread < 2) {
let value = "Buy some bread";
shoppingItemsCart.push(value);
}
if (this.props.fruit < 10) {
let value = "Buy some …Run Code Online (Sandbox Code Playgroud) 我一生都无法弄清楚这一点。以下站点托管在 Netlify 上并启用了预渲染。检查页面时,所有 OG 标签都是正确的。这些标签是使用 react-helmet 注入的。
https://browniepoints.africa/opportunities/volunteer-at-a-soup-kitchen-every-week-on-thursdays
在 Facebook 调试器上抓取上述 URL 时,它会响应:
The following required properties are missing: og:url, og:type, og:title, og:image, og:description, fb:app_id
Run Code Online (Sandbox Code Playgroud)
唯一应该存在的错误/警告之一是app_id,我不在乎。
我已经等了 48 多个小时才清除缓存,我尝试使用附加到 URL 的查询字符串进行抓取,并且图像具有绝对 URL。但即使是描述标签也没有通过。
请使用 react-helmet 和 Netlify 的人对这个问题有明确的认识吗?
在下面的Angularjs片段中,默认显示整个表,并在开始键入时对其进行过滤.
如果最佳做法是将其更改为默认情况下不显示结果,并且仅在搜索查询中至少有3个结果匹配后才开始显示结果?
奖金问题,如果输入的最少2个字符,您将如何仅显示结果?
Html:
<div ng-app="myApp">
<div ng-controller="PeopleCtrl">
<input type="text" ng-model="search.$">
<table>
<tr ng-repeat="person in population.sample | filter:search">
<td>{{person.name}}</td>
<td>{{person.job}}</td>
</tr>
</table>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
Main.js:
var myApp = angular.module('myApp', []);
myApp.factory('Population', function () {
var Population = {};
Population.sample = [
{
name: "Bob",
job: "Truck driver"
}
// etc.
];
return Population;
});
function PeopleCtrl($scope, Population) {
$scope.people = Population;
}
Run Code Online (Sandbox Code Playgroud) 的Gemfile:
gem 'capistrano', '~> 3.0.0'
gem 'capistrano-rails'
gem 'capistrano-bundler'
gem 'capistrano-rvm'
gem 'capistrano3-puma'
Run Code Online (Sandbox Code Playgroud)
Deploy.rb:
set :rvm_type, :user
set :rvm_ruby_version, '2.1.1'
set :default_env, { rvm_bin_path: '~/.rvm/bin' }
Run Code Online (Sandbox Code Playgroud)
Production.rb
namespace :rails do
desc "Open the rails console on primary app server"
task :console do
on roles(:app), primary: true do
execute_interactively "#{current_path}/script/rails console RAILS_ENV=production"
end
end
def execute_interactively(command)
cmd = "ssh -l deploy 255.255.255.255 -p 21 -t 'cd #{deploy_to}/current && #{command}'"
info "Connecting to 255.255.255.255"
exec cmd
end
end
Run Code Online (Sandbox Code Playgroud)
Capfile:
require 'capistrano/setup'
require …Run Code Online (Sandbox Code Playgroud) 如何使用深层嵌套数组过滤数组?给定以下2个数组,我需要结果是只有rice cakes和gluten-free-pizza对象的数组:
const foodsILike = ['gluten-free', 'carb-free', 'flavor-free'];
const foodsAvailable = [
{ name: 'pasta', tags: ['delicious', 'has carbs']},
{ name: 'gluten-free-pizza', tags: ['gluten-free']},
{ name: 'pizza', tags: ['delicious', 'best meal of the year']},
{ name: 'rice cakes', tags: ['flavor-free']}
]
Run Code Online (Sandbox Code Playgroud)
我尝试了以下只返回所有内容(4个对象):
var result = foodsAvailable.filter(function(food) {
return foodsILike.filter(function(foodILike) {
return foodILike === food;
})
})
result
// Array [ Object, Object, Object, Object]
Run Code Online (Sandbox Code Playgroud) facebook ×2
javascript ×2
reactjs ×2
ruby ×2
angularjs ×1
arrays ×1
capistrano ×1
capistrano3 ×1
css ×1
heroku ×1
netlify ×1
omniauth ×1
prerender ×1
react-helmet ×1
ssl ×1