Перевод "Rails in a nutshell Chapter 4. Active Resource" | Participants
|
- Statistics
- Participants
- Translate into Russian
- Translation result
- 15% translated in draft.
If you do not want to register an account, you can sign in with OpenID.
Rails in a nutshell Chapter 4. Active Resource | ||
Chapter 4. Active Resource | ||
Today more than ever, applications need to be able to interoperate not only with browser based clients, but with other applications. In order to accomplish interoperability web applications commonly offer a web service API. A web service API offers remote access to an application over a network, such as the internet. In the past web service APIs were commonly offered using complex and bulky SOAP based web services that were slow to implement and hard to understand. With the advent of Rails and the rise of REST based web services there has become a faster, simpler way to offer and consume web services. | Сегодня, более чем когда-либо, приложения должны уметь работать не только с клиентами на основе веб-браузеров, но и с другими приложениями в качестве клиентов. Для достижения такого взаимодействия веб-приложения обычно предлагают веб-сервисные API. Веб-сервисные API реализуют удаленный доступ к приложению через сеть, такой как Интернет. В прошлом веб-сервисные API обычно реализовывались с помощью сложного и большого SOAP-протокола, который сложен для понимания и реализации. С появлением Rails и развитием REST веб-сервисов мы получили более быстрый и простой способ реализации и работы с веб-сервисами. | |
Rails makes it easy to offer multiple different content types, or representations, of a particular resource through a single controller action. Being able offer multiple representations of a resource through a single controller action makes adding support for non browser based HTML clients as simple as adding a few lines of code that returns the resource in the representation the client requested. The controller layout and logic of the application is preserved with the added benefit of interoperability with new clients. | Rails позволяет легко предоставить несколько различных типов контента, или представлений, как ресурсов предоставляемых действием контроллера . Возможность предоставить несколько представлений ресурса | |
Active Resource provides the tools to quickly and easily consume REST based web services conforming to the Rails RESTful URI structure and protocol conventions. Active Resource automatically maps the response from any conforming service to rich Ruby objects. Active Resource also provides all the lifecycle methods needed to easily find, create, update, and delete resources without having to write any code. | ||
Following is a simple definition for an Active Resource model: | ||
class Person < ActiveResource::Base | ||
self.site = "http://webservice.example.com" | ||
end | ||
With only this simple subclass of ActiveResource::Base and a site definition, which tells Active Resource the base endpoint URI of the remote web service, it is possible to find, create, update, and delete resources : | ||
# Build and save a new person |
