我有一个check_captcha回调函数它认为,如果$row是==0或== 1(此信息是从SQL查询).
问题是我无法调用它,$self->form_validation->set_rule('captcha', 'call_back_check_captcha')因为我的函数接受了$rowvar.我正在调用它的方式现在我得到一个无法访问错误消息.我怎样才能做到这一点?
function check_captcha( $row)
{
if($row ==0)//didnt find any
{
$this->form_validation->set_message('captcha', 'text dont match captcha');
return FALSE;
}
else
{
return TRUE;
}
}
function create_member()
{
$past = time() - 7200;
$this->db->query("DELETE FROM captcha WHERE captcha_time <".$past);
$sql = "SELECT COUNT(*) AS count FROM captcha WHERE word =? AND ip_address =?";
$binds = array($_POST['captcha'], $this->input->ip_address(), $past);
$query= $this->db->query($sql, $binds);
$row = $query->row(); //row query rows : …Run Code Online (Sandbox Code Playgroud) noobie在这里希望你们不要介意!我试图查询我的user/id/pictures.json,但它返回的是属性cus我做了一个通用的format.json {render:json => @ photo.to_json()}.我的问题是如何创建和封装图像中的实际数据,以便我的客户可以将数据转换为图像?而且除了图像的路径之外我还需要创建什么(属性明智)(比如你只有无用的属性,例如:height content_type,description,thumbnail file_name)?
这是我到目前为止在我的index.json.erb中尝试的内容
}
<% @photos.each do |photo|%>
data: <%= StringIO.new(Base64.encode64(photo.public_filename(:large))) %>
<%end%>
}
Run Code Online (Sandbox Code Playgroud)
我回来了
{
data: #<StringIO:0x1058a6cd0>
}
Run Code Online (Sandbox Code Playgroud)
这不是我正在寻找的IMGdata
嗨伙计们,我有这个我修复过的问题,但我知道修复是没有做正确的方法.有人能指出我正确的方向进行正确的修复吗?
所以基本上我用iOS sim创建一个对象,RESTkit postObject我收到了这条消息
Processing PeopleController#create (for 127.0.0.1 at 2012-01-13 03:55:46) [POST]
Parameters: {"name"=>"data"}
Person Create (0.4ms) INSERT INTO "people" ("created_at", "updated_at", "name")
VALUES('2012-01-13 11:55:46', '2012-01-13 11:55:46', NULL)
Completed in 27ms (View: 1, DB: 0) | 200 OK
Run Code Online (Sandbox Code Playgroud)
一位优秀的先生们指出,我的创建函数中的类只接受了一个我忽略的人类.
def create
@person = Person.new(params[:person]) , thus looking for {"person" => {"name"=>"data"}}
Run Code Online (Sandbox Code Playgroud)
我这样做了
@person =Person.new(name:=>params[:name])因为我现在只发送{"name"=>"data"}
它创建好,我可以看到我的ios sim上的条目,但我知道这不是正确的方式应该{"person" => {"name"=>"data"}}发送到原始功能的正确方法.加上我的错误找不到keyPath的对象映射:"有什么想法吗?提前thnx!这是我的xcode
@interface Data: NSObject{// imaginary over arching class
Person * person;
NSArray *dog;
@property (nonatomic, retain) Person …Run Code Online (Sandbox Code Playgroud) 嗨,大家好所以我用NSJSONSerialization dataWithJSONObject:jsonDict选项:NSJSONWritingPrettyPrinted错误:零]命令写入JSON.它看起来很好,当我发布到Rails服务器时,"第一个名称"仍然存在.任何人都可以帮忙
NSArray *objects = [NSArray arrayWithObjects:@"firstname", @"lastname",nil];
NSArray *keys = [NSArray arrayWithObjects:@"dave", @"lu", nil];
NSDictionary *questionDict = [NSDictionary dictionaryWithObjects:keys forKeys:objects];
NSArray *objects2 = [NSArray arrayWithObjects:@"utf8",
@"authenticity_token",@"check_i_ndatum", @"commit",nil];
NSArray *keys2 = [NSArray arrayWithObjects:@"1", @"xx",questionDict,@"Create Check i
Nadtum", nil];
NSDictionary *jsonDict = [NSDictionary dictionaryWithObjects:keys2 forKeys:objects2];
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDict
options:NSJSONWritingPrettyPrinted error:nil];
NSURL * url =[NSURL URLWithString:@"http://192.168.1.105:3000/check_i_ndata"];
//the request
NSMutableURLRequest *request =[NSMutableURLRequest requestWithURL:url
cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60];
//bind req w/ json
[request setHTTPMethod:@"POST"];
//[request setValue:@"check_i_ndata" forHTTPHeaderField:@"Accept"];
[request setValue:[NSString stringWithFormat:@"%d",[jsonRequestData length]]
forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody:jsonRequestData]; …Run Code Online (Sandbox Code Playgroud) rest ruby-on-rails nsurlrequest ruby-on-rails-3 nsjsonserialization
api ×1
codeigniter ×1
json ×1
nsurlrequest ×1
objective-c ×1
php ×1
rest ×1
restkit ×1
xcode ×1