我有一个功能来检索用户的个人资料.
app.get('/api/user/profile', function (request, response)
{
// Create the default error container
var error = new Error();
var User = db.User;
User.find({
where: { emailAddress: request.user.username}
}).then(function(user)
{
if(!user)
{
error.status = 500; error.message = "ERROR_INVALID_USER"; error.code = 301;
return next(error);
}
// Build the profile from the user object
profile = {
"firstName": user.firstName,
"lastName": user.lastName,
"emailAddress": user.emailAddress
}
response.status(200).send(profile);
});
});
Run Code Online (Sandbox Code Playgroud)
调用"find"函数时,它会在启动服务器的控制台上显示select语句.
Executing (default): SELECT `id`, `firstName`, `lastName`, `emailAddress`, `password`, `passwordRecoveryToken`, `passwordRecoveryTokenExpire`, `createdAt`, `updatedAt` FROM `Users` AS `User` …Run Code Online (Sandbox Code Playgroud) [编辑:]问题已经解决.我没有正确链接我的代表UIBuilder.代码很好!
我想在键盘出现时调整scrollview的大小.我去了开发人员文档并找到了这些信息.
在左侧"管理键盘".
在文档中,它显示了一些代码来检测键盘的大小,然后调整大小UIScrollView.我NSLog在函数代码中放了一条消息,- (void)keyboardWasShown:(NSNotification*)aNotification所以我看到函数实际上被调用了,但是当我尝试NSLog使用kbSize.height时,它的值总是为0.
为什么苹果为此目的提供的代码不起作用?
- (void)keyboardWasShown:(NSNotification*)aNotification
{
NSDictionary* info = [aNotification userInfo];
CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
UIEdgeInsets contentInsets = UIEdgeInsetsMake(0.0, 0.0, kbSize.height, 0.0);
scrollView.contentInset = contentInsets;
scrollView.scrollIndicatorInsets = contentInsets;
// If active text field is hidden by keyboard, scroll it so it's visible
// Your application might not need or want this behavior.
CGRect aRect = self.view.frame;
aRect.size.height -= kbSize.height;
if (!CGRectContainsPoint(aRect, activeField.frame.origin) …Run Code Online (Sandbox Code Playgroud) 我有一个kendo UI网格和一个数据源.当我调用Update方法时,我测试一个变量,如果条件为false,我不想发送请求.
目前我有:
$scope.MySource = new kendo.data.DataSource({
update: {
url: function (lista) {
if (testVariable== true) {
testVariable= false;
return "api/Liste/PutLista/" + lista.Id
}
else {
$scope.MySource.cancelChanges();
}
},
type: "PUT",
dataType: "json",
beforeSend: function (req) {
var auth = $window.sessionStorage.token;
req.setRequestHeader('Authorization', 'Bearer ' + auth);
}
Run Code Online (Sandbox Code Playgroud)
如果testVariable为false我取消更新,但我仍然看到ajax请求
http://localhost:61927/index.html with PUT method.
Run Code Online (Sandbox Code Playgroud)
如果testVariable是假的,我如何阻止请求?
我有一个我用Symfony2编写的应用程序.我创建了一个Account实体,并使用注释创建了一个名为AccountRepository的存储库.在AccountRepository对象中,我创建了一个函数来运行一些业务逻辑,该逻辑传递给外部供应商并在其站点上创建用户,并返回信息对我们来说,我可以将他们的用户与我们的帐户实体相关联.创建该用户的一部分包括通过信用卡令牌发送.然后,他们返回我想存储的一些有限的信用卡数据并与我们的帐户关联,因此在创建对象并插入适当的数据后我有一个实体AccountCard,我无法从存储库请求实体管理器并保持AccountCard执行$ em变量上的print_r什么也没有显示,但我读过的所有内容都告诉我,我应该能够做到这一点.我究竟做错了什么?
<?php
namespace Openbridge\CommonBundle\Entity\Repository;
use Doctrine\ORM\EntityRepository;
use Openbridge\CommonBundle\Entity\Account as Account;
use Openbridge\CommonBundle\Entity\AccountCard as AccountCard;
use Openbridge\CommonBundle\Entity\AccountAddress as AccountAddress;
/**
* AccountRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class AccountRepository extends EntityRepository
{
public function __construct()
{
}
function createVendorUser(Account $account, $userData = array())
{
// Request new user from vendor code here. (this works)
$ac = new AccountCard();
// setters for $ac data here.
// Get …Run Code Online (Sandbox Code Playgroud) 当用户点击'x'+ Enter时,我正试图找到一种终止循环的方法.我希望循环只在后台继续运行,直到用户取消它.
这些方面的东西:
while gets.chomp != 'x'
puts 'looping...'
sleep 1
end
Run Code Online (Sandbox Code Playgroud)
我是编程的初学者,并且已经广泛搜索了如何做到这一点,所以任何帮助都将深表感谢.
好的,所以我正在阅读"使用Rails进行敏捷Web开发"并开始使用软件仓库应用程序.对于那些有本书的人来说,这是第9.3章迭代D3:添加一个按钮.
在本节之前,我们创建了一个会话来保存我们的"购物车"
class ApplicationController < ActionController::Base
protect_from_forgery
private
def current_cart
Cart.find(session[:cart_id])
rescue ActiveRecord::RecordNotFound
cart = Cart.create
session[:cart_id] = cart.id
cart
end
end
Run Code Online (Sandbox Code Playgroud)
使我们创建的任何控制器扩展ApplicationController都可以访问我们的购物车.
在本节中,我们编辑LineItemsController类的"create"函数,该函数扩展了ApplicationControler.
原始的create方法如下所示
def create
@line_item = LineItem.new(params[:line_item])
respond_to do |format|
if @line_item.save
format.html { redirect_to @line_item, notice: 'Line item was successfully created.' }
format.json { render json: @line_item, status: :created, location: @line_item }
else
format.html { render action: "new" }
format.json { render json: @line_item.errors, status: :unprocessable_entity }
end
end
end
Run Code Online (Sandbox Code Playgroud)
这本书说如果这样修改.
def create
@cart = current_cart …Run Code Online (Sandbox Code Playgroud) ruby ×2
doctrine-orm ×1
ios ×1
ipad ×1
iphone ×1
javascript ×1
jquery ×1
kendo-grid ×1
kendo-ui ×1
keyboard ×1
node.js ×1
objective-c ×1
php ×1
sequelize.js ×1
symfony ×1