是否有任何可能的方法使grabToImage()缓冲区与GUI中显示的不同?我ChartView在GUI中使用没有图例,并希望将其导出为PNG图例.所以我尝试:
chartView.legend.visible = true
chartView.update()
chartView.grabToImage(function(result) {
console.log("grabbed")
var path = filename.toString().replace(/^(file:\/{2})/,"");
console.log(path + result.saveToFile(path));
chartView.legend.visible = false
update();
});
Run Code Online (Sandbox Code Playgroud)
但是这些更新只有在控件出来之后才会发生,因此我不会在PNG中绘制传奇.另外,我希望图例的外观对用户来说是不可察觉的.在QML中有没有办法做到这一点?
我在AngularJS中有一个前端,在RoR中有后端与Devise + Doorkeeper + RocketPants.现在我已正确使用CORS,我可以成功地从我的API获取json响应(如果我关闭门卫保护).但是现在我正在尝试实现用户密码凭证流程:
在门卫上:
resource_owner_from_credentials do |routes|
request.params[:user] = {:email => request.params[:username], :password => request.params[:password]}
request.env["devise.allow_params_authentication"] = true
request.env["warden"].authenticate!(:scope => :user)
end
Run Code Online (Sandbox Code Playgroud)
在angularjs(src:nils-blum):
var payload = "username="+username+"&password="+password+"&" +
"client_id="+client_id+"&client_secret="+client_secret+
"&grant_type=password"
$http({method: 'POST',
url: scope.booksh_server + '/oauth/token',
data: payload,
headers: {'Content-Type':'application/x-www-form-urlencoded'}
}
).success(function (data) {
tokenHandler.set(data.access_token);
scope.$broadcast('event:authenticated');
});
Run Code Online (Sandbox Code Playgroud)
注意:Nils的方法使用有效载荷作为对象与params,而不是字符串.在我的情况下,它给我带有效负载的POST,而不是FORM params,因此不起作用.
当我输入错误的用户/密码时,rails log说:
Started POST "/oauth/token" for 127.0.0.1 at 2013-11-22 15:21:08 +0400
Doorkeeper::Application Load (0.5ms) SELECT "oauth_applications".* FROM "oauth_applications" WHERE "oauth_applications"."uid" = '981d6d654f5e709b2ca3437401c993a6d09cc91cc3fb16b8e2b3191e6421029c' AND "oauth_applications"."secret" = 'f92c4ec969525352bd03ec1eb810a9952cd0814d37ce5b2b02e8a928b2561e10' ORDER …Run Code Online (Sandbox Code Playgroud) 我正在研究用RocketPants制作的 Rails API 。对于 JSON 序列化,我使用active_model_serializers,对于 OAuth - Doorkeeper。
问题在于current_user访问 class UserSerializer < ActiveModel::Serializer. 错误:
NameError (undefined local variable or method `request' for #<UserSerializer:0xb5892118>)
Run Code Online (Sandbox Code Playgroud)
current_user助手使用这个片段:
User.find(doorkeeper_token.resource_owner_id) if doorkeeper_token
Run Code Online (Sandbox Code Playgroud)
并且doorkeeper_token是:
def doorkeeper_token
methods = Doorkeeper.configuration.access_token_methods
@token ||= OAuth::Token.authenticate request, *methods
end
Run Code Online (Sandbox Code Playgroud)
据我发现,request中没有可访问的对象Serializer。我怎样才能使其易于访问?还是应该有其他的方式来实现current_user?
提前致谢