在我的设计中
class XyzController < ApplicationController
def custom_signup
user = User.new(first_name: "xyz", last_name: "twr", password: "password", password_confirmation: "password")
redirect_to user_registration_path(user)
end
我想从另一个控制器中调用此注册#create方法
extension Alamofire.Request {
class func authResponseSerializer() -> Serializer {
return {request, response, data in
if data == nil {
return (nil, nil)
}
var jsonError: NSError?
let jsonData:AnyObject?
do {
jsonData = try NSJSONSerialization.JSONObjectWithData(data!, options: [])
} catch var error as NSError {
jsonError = error
jsonData = nil
} catch {
fatalError()
}
if jsonData == nil || jsonError != nil {
return (nil, jsonError)
}
let json = JSON(jsonData!)
if json.error != nil || json == nil {
return (nil, json.error)
}
var auth:Authorization = Authorization(json: json)
return (auth, nil)
}
}
func responseAuthorization(completionHandler: (NSURLRequest, NSHTTPURLResponse?, Result<Authorization>) -> Void) -> Self {
return response(responseSerializer: Request.authResponseSerializer(), completionHandler: completionHandler)
}
我想在custom_signup方法中注册用户。 有没有办法做到这一点?