【実装方法】
とても簡単です。ActiveRerordと同じで、以下ようにActiveResourceを継承してあげればOK。
1 2 3 4 5 |
<textarea class="ruby" cols="60" rows="5" name="code"> class Person < ActiveResource::Base self.site = "http://api.people.com:3000/" end </textarea> |
【テスト】
コンソールでテストしてみます。
1 2 3 4 5 |
<textarea class="ruby" cols="60" rows="5" name="code"> # Find a person with id = 1 ryan = Person.find(1) Person.exists?(1) #=> true </textarea> |
実装がめちゃくちゃ早いです。。
【参考サイト】
・本家ドキュメント ActiveResource
http://api.rubyonrails.org/classes/ActiveResource/Base.html