I am using apn_on_rails to alert using iphone push with rails.
At the moment, the check on the token is no longer valid, because the check requires a space every 8 characters: validates_format_of: token, with => / ^ [a-z0-9] {8} \ s [a-z0-9] { 8} \ s [a-z0-9] {8} \ s [a-z0 -9] {8} \ s [A-z0-9] {8} \ s [A-z0-9] {8} \ s [A-z0-9] {8} \ s [A-z0-9] {8} $ /
http://github.com/markbates/apn_on_rails/blob/master/lib/apn_on_rails/app/models/apn/device.rb
But the device token I got from Objective-C does not have a place.
So I would like to override the check to do this: validates_format_of: token: with => / ^ [a-z0-9] {64} $ /
How can I do this without changing the source inside the gem?
Thank.
Or do a code check:
[56, 48, 40, 32, 24, 16, 8].each { |i| code.insert(i, ' ') }
You are not the first in this matter - I found the following article entitled Useful Information on Rails Validation with Metaprogramming .
, , . , . , wesgarrison :
def token= token @token = [56, 48, 40, 32, 24, 16, 8].each { |i| token.insert(i, ' ') } end
- , .
Source: https://habr.com/ru/post/1732812/More articles:Memory Leak Warning I Can't Solve - memory-managementНевозможно повлиять на содержимое UITextView с помощью initWithCoder - iosReading values from a file and assigning it to a variable in batch script - windowsHow to prevent Qt buttons from appearing in a separate frame? - pythonremoving all elements from an xml file except the root element of C # - c #RED5 server and flash question - flashVim class lookup - c ++Fighting SelectList in ASP.NET MVC 2 - c #UITabBar notification icon - iphoneAmbiguity, including std class libraries - c ++All Articles