「警告不能驗證CSRF令牌真實性」當我試圖從RestKit
發帖,有在Rails的控制檯的警告:Rails的顯示:從RestKit POST
Started POST "/friends" for 127.0.0.1 at 2012-04-16 09:58:10 +0800
Processing by FriendsController#create as */*
Parameters: {"friend"=>{"myself_id"=>"m001", "friend_id"=>"f001"}}
WARNING: Can't verify CSRF token authenticity
(0.1ms) BEGIN
SQL (1.7ms) INSERT INTO `friends` (`friend_id`, `myself_id`) VALUES ('f001', 'm001')
(1.1ms) COMMIT
Redirected to http://127.0.0.1:3000/friends/8
Completed 302 Found in 6ms (ActiveRecord: 3.0ms)
下面是客戶端代碼:
NSMutableDictionary *attributes = [[NSMutableDictionary alloc] init];
[attributes setObject: @"f001" forKey: @"friend_id"];
[attributes setObject: @"m001" forKey: @"myself_id"];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObject:attributes forKey:@"friend"];
[[RKClient sharedClient] post:@"/friends" params:params delegate:self];
我該如何擺脫警告?
爲了避免打開一個大洞,我建議skiping驗證只爲你的方法。 'skip_before_filter:verify_authenticity_token:僅=> [:your_method]' – 2012-05-31 23:38:23
那些剪切和粘貼上面的代碼:'skip_before_filter:verify_authenticity_token,:僅=> [:your_method]'馬克忘記逗號。 DId沒有看到編輯按鈕。 – pjammer 2013-07-05 17:02:37
感謝這個詳細信息... – 2015-06-17 06:30:57