我在前端使用了ng-token-auth,在后端使用了devise_token_auth.现在我要在我的网站上实现omniauth-facebook和omniauth-goole登录.但是我已经用以下功能完成了facebook登录
在config.js(ng-token-auth)中
$scope.handleBtnClick = function() {
console.log('here its')
$auth.authenticate('facebook')
.then(function(resp) {
// handle success
})
.catch(function(resp) {
// handle errors
});
};
Run Code Online (Sandbox Code Playgroud)
此时,登录成功,但是当它重定向时,它会在浏览器页面中显示以下错误
{"errors":["使用POST/sign_in登录.不支持GET."]}
的routes.rb
mount_devise_token_auth_for 'User', at: 'auth',:controllers => { :omniauth_callbacks => 'omniauth' }
Run Code Online (Sandbox Code Playgroud)
devise.rb
config.omniauth :facebook, 'APP_KEY', 'APP_SECRET',{ :scope => 'email' }
Run Code Online (Sandbox Code Playgroud)
omniauth控制器
class OmniauthController < Devise::OmniauthCallbacksController
def facebook
byebug
@user = User.from_omniauth(request.env["omniauth.auth"])
sign_in_and_redirect @user
end
end
Run Code Online (Sandbox Code Playgroud)
这里是我的服务器日志
开始获取"/ omniauth/facebook?auth_origin_url = http%3A%2F%2Flocalhost%3A3000%2F%23%2F&omniauth_window_type = sameWindow&resource_class = User"for 127.0.0.1 at 2016-03-12 …
我是 mongoose 和 mongoDB 的新手,我有以下查询,运行时会抛出以下错误。如果有人可以帮助我处理问题并仍然得到相同的输出,那就太好了
//interview.model.js => mongodb show name as interview
module.exports = mongoose.model('Interview', interviewSchema);
//candidate.model.js => mongodb show name as candidate
module.exports = mongoose.model('Candidate', candidateSchema);
const [result, err] = await of(Interview.aggregate([
{
$match: {
...filterQuery,
}
},
{
$lookup: {
'from': 'candidates',
'localField': 'candidateId',
'foreignField': '_id',
'as': 'candidateId',
pipeline: [
{ $match: { 'candidateId.interviewCount': 0 }},
{ $project: { firstName:1, status:1, avatar:1 } }
]
}
},
]))
Run Code Online (Sandbox Code Playgroud) 在android我有一个主要的浅色和状态栏,我可以使这些之间的渐变#F3A183和#EC6F66?如果是这样我怎么能实现这个目标?
我有model profile.rb以下关联
class User < ActiveRecord::Base
has_one :profile
end
class Profile < ActiveRecord::Base
has_many :skills
belongs_to :user
end
Run Code Online (Sandbox Code Playgroud)
我有model skills.rb以下关联
class Skill < ActiveRecord::Base
belongs_to :profile
end
Run Code Online (Sandbox Code Playgroud)
我在技能表中有以下条目
id: name: profile_id:
====================================================
1 accounting 1
2 martial arts 2
3 law 1
4 accounting 2
5 journalist 3
6 administration 1
Run Code Online (Sandbox Code Playgroud)
等等,我如何查询所有配置文件,假设"会计"和"管理"技能,这将是id为1的配置文件,考虑到上述重新编码.到目前为止,我试过以下
Profile.includes(:skills).where(skills: {name: ["accounting" , "administration"]} )
Run Code Online (Sandbox Code Playgroud)
但不是找到配置文件id 1- 它得到了我[ 1, 2 ]因为id为2的配置文件"accounting" skills并且它"IN" operation正在数据库中执行
注意:我正在使用postgresql …
我正在研究chating模块.为此,我用过private_pub gem.在这个模块中,我已经制作了三个频道,但我不能在这里提到所有这些频道,因为它会显示一个非常非常大的页面.所以让我们坚持一个渠道.
我点击具有通道链接"<%= subscribe_to "/conversations/send_invitation" %>",然后ajax工作和去"conversations/send_invitation"(只有一次-这是确定),并在我的"/conversations/send_invitation"我有
def send_invitation
@conversation = Conversation.new(conversation_params)
respond_to do |format|
format.js { render :layout => false }
format.html
end
end
Run Code Online (Sandbox Code Playgroud)
然后在我的send_invitation.js.erb文件中我有以下内容
<% publish_to "/conversations/send_invitation" do %>
var recipient_id = "<%=@conversation.recipient.id %>";
var current_temp_user = $("#current_temp_user").val();
if(recipient_id == current_temp_user){
console.log('here')
$("#invitation_div").html("<%=j(render :partial => '/restaurants/invitation')%>");
card_modal = $('#invitation_card').modal();
card_modal.modal('show');
}
<% end %>
Run Code Online (Sandbox Code Playgroud)
这是我的application.js档案
//= require jquery
// require jquery-ui
//= require …Run Code Online (Sandbox Code Playgroud) 今天我遇到了一些奇怪的Array元素赋值行为:
arr = ["a","b"]
arr2 = [1,2]
arr.unshift(arr2) #= [[1, 2], "a", "b"]
arr.push(arr2) #=> ["a", "b", [1, 2]]
Run Code Online (Sandbox Code Playgroud)
然而,这是有道理的:
arr[0,0] = arr2 #=> [1, 2, "a", "b"]
Run Code Online (Sandbox Code Playgroud)
我知道在[0,0]第一个零中index,第二个是从该数组开始生效的元素数量index.
在我的想法中它应该与它相同unshift,但事实并非如此.
任何人都可以解释这种行为吗?
我使用Stripe gem作为我的付款方式。根据其文档,我确实尝试检索我针对客户添加的卡。客户检索效果很好
customer = Stripe::Customer.retrieve("cus_DWcUQOutnrAD4s")
Run Code Online (Sandbox Code Playgroud)
但是当我尝试使用取回卡时
card = customer.sources.retrieve("card_1D5a3J2eZvKYlo2CDJ62mrSM")
Run Code Online (Sandbox Code Playgroud)
它抛出异常说
NoMethodError:<Stripe::Customer: 0x007faae89500c0> 的未定义方法“源”
我用谷歌搜索了很多,但找不到这样的问题,这让我觉得我可能是唯一面临这个问题的人。我确信stripe安装正确,因为我成功添加了customer,card但subscription检索它会card引发错误。
我正在实施 AWS ClientManager 来获取 AWS 中保存的秘密变量。我的初步实现如下:
// Load the AWS SDK
var AWS = require('aws-sdk'),
region = "us-west-2",
secretName = "secretName",
accessKeyId = myAccessKey,
secretAccessKey = mySecretAccessKey,
secret,
decodedBinarySecret;
var client = new AWS.SecretsManager({
region: region,
});
client.getSecretValue({SecretId: secretName}, function(err, data) {
if (err) {
console.log("Error Happened");
console.log(err);
}
else {
if ('SecretString' in data) {
secret = data.SecretString;
} else {
let buff = new Buffer(data.SecretBinary, 'base64');
decodedBinarySecret = buff.toString('ascii');
}
}
});
Run Code Online (Sandbox Code Playgroud)
当我启动服务器时,它抛出以下异常
{ UnrecognizedClientException:请求中包含的安全令牌无效。message: '请求中包含的安全令牌无效。', code: 'UnrecognizedClientException', …
我知道在postgres的查询中有引号或区分大小写错误时会发生这种错误.其实我具有我试图通过命令行中我的Heroku数据库导入.sql文件,但不断有这个错误.我的.sql文件包含这些查询
INSERT INTO "places" ("Name", "Address") VALUES
('Cookshop Restaurant &', ' Bar'),
('Cafeteria', '119 7th Ave, New York, NY 10011'),
('Franchia Vegan Cafe', '12 Park Ave, New York, NY 10016');
Run Code Online (Sandbox Code Playgroud) 在Rails Guide中,我发现了以下三个代码段
ActionCable.server.broadcast("chat_#{params[:room]}", data)
Run Code Online (Sandbox Code Playgroud)
这个简单的广播将数据发送到特定的聊天室
而broadcast_to如下所示,似乎到当前用户订阅的信道内发送数据的所有聊天室。
WebNotificationsChannel.broadcast_to(
current_user,
title: 'New things!',
body: 'All the news fit to print'
)
Run Code Online (Sandbox Code Playgroud)
这是另一种广播的broadcast_for-我无法得到任何例子。
我的问题是这三个之间的实际区别是什么以及何时使用每个'em-预先感谢
ruby ×3
javascript ×2
node.js ×2
postgresql ×2
activerecord ×1
android ×1
arrays ×1
aws-sdk ×1
devise ×1
heroku ×1
jquery ×1
loopback ×1
mongodb ×1
mongoose ×1
omniauth ×1