나는 초보적인 API를 시도하고 있지만, 어느 정도기로에 서서 진행 방법이 확실하지 않습니다. 일반적인 요지는 /authenticate.json에 사용자 이름과 암호를 제공하고 액세스 토큰을받는 대신에 제공된다는 것입니다.RoR POST 요청으로 인해 라우팅 오류가 발생합니다.
GET 요청을하면 필요한 정보를 얻을 수 있습니다. 내가 POST를 통해 그것을 시도 할 경우 오류가 발생합니다 :
No route matches {:action=>"show", :controller=>"users", :id=>#<User access_token: "8922a3718bbe2a441a5ddddece3053a647941863b5ff2cad007...">}
routes.rb을 컨트롤러 내의 인증합니다 정의는 (내가 해요, 그것은 cludgy 알고 다음과 같습니다
match '/authenticate' => 'user_functions#authenticate', :via => [:post, :get]
def authenticate
if params['email'] and params['password']
userSearch = User.find(:all, :conditions => ['email = ?', params[:email]], :limit => 1)
if userSearch.count == 1
hash = Digest::SHA2.new << "#{userSearch.first.password_salt}#{params['password']}"
if hash.hexdigest == userSearch.first.password_hash
access_array = {"access_token" => userSearch.first.access_token}
userAccessDetails = User.find(userSearch.first.id, :select => "access_token")
respond_with userAccessDetails
else
respond_with 'Invalid credentials'
end
else
respond_with 'Failed'
end
else
respond_with 'No credentials provided'
end
끝)의 RoR/루비와 정확히 유창하지
누구든지 올바른 방향으로 나를 도와 주거나 지적 할 수 있다면 감사하게 생각합니다. 감사.
당신은 아름다운 사람을! 고마워, 매력처럼 일했다. –
환영합니다. 답변을 수락하는 것을 주저하지 마십시오.) – vdaubry