我有一个 Rails 应用程序,需要用户使用 devise 登录。登录后,用户可以创建位置并添加菜单。我想通过使用 AFnetworking 的 iOS 应用程序访问 api,但是在验证 iOS 应用程序时,我想访问整个 API 而不仅仅是一个位置数据。
示例:用户打开 ios 应用程序,单击位置,选择位置,选择啤酒菜单,显示来自 api 的啤酒列表。
当 rails 端的身份验证允许访问一个位置结果时,我该怎么做?
我希望 iOS 用户能够访问整个 api,我在 rails 控制台中将其视为 Location.all 和 Beer.all
调用 beers.json 端点时我在 xcode 中得到的输出
2013-02-22 09:44:25.834 BeerList[23137:c07] Error fetching beers!
2013-02-22 09:44:25.835 BeerList[23137:c07] Error Domain=com.alamofire.networking.error Code=-1011 "Expected status code <NSIndexSet: 0x6a3ee70>[number of indexes: 100 (in 1 ranges), indexes: (200-299)], got 500" UserInfo=0xbe29090 {NSErrorFailingURLKey=http://localhost:3000/beers.json, NSLocalizedDescription=Expected status code <NSIndexSet: 0x6a3ee70>[number of indexes: 100 (in 1 ranges), indexes: (200-299)], got 500}
我认为这是因为 iOS 应用程序未经过身份验证。如果我要传递用户名和密码,我假设它会给我该用户位置的数据,但不是所有位置。有没有办法对 iOS 应用程序进行身份验证,以便它可以检索所有位置数据?