<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0"
  xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Tom Counsell's Soks Wiki Early experiences with Active Resource</title>
    <link>http://tom.counsell.org</link>
    <description>A vanity site</description>
    <image>
      <url>http://tom.counsell.org/Static/logo.png</url>
      <title>Tom Counsell's Soks Wiki</title>
      <link>http://tom.counsell.org</link>
    </image>
    <item>
      <title>You can then get an object:</title>
      <link>http://tom.counsell.org/view/EarlyExperiencesWithActiveResource</link>
      <description>You can then get an object:&lt;br /&gt;&amp;#8230;&lt;br /&gt;&lt;br /&gt;There is an error if you try and @find(:all)@ and no objects exists.&lt;br /&gt;&amp;#8230;&lt;br /&gt;Content was also deleted</description>
      <author>tamc2</author>
      <pubDate>Fri, 30 Jun 2006 22:23:08 +0000</pubDate>
    </item>
    <item>
      <title>[[ActiveResource::Connection =&gt; http://dev.rubyonrails.org/browser/trunk/activeresource/lib/active_resource/connection.rb#L54]]</title>
      <link>http://tom.counsell.org/view/EarlyExperiencesWithActiveResource</link>
      <description>[[ActiveResource::Connection =&gt; http://dev.rubyonrails.org/browser/trunk/activeresource/lib/active_resource/connection.rb#L54]]&lt;br /&gt;&amp;#8230;&lt;br /&gt;Content was also deleted</description>
      <author>tamc2</author>
      <pubDate>Fri, 30 Jun 2006 22:05:04 +0000</pubDate>
    </item>
    <item>
      <title>Last updated 23:04 BST Fri 30 June.</title>
      <link>http://tom.counsell.org/view/EarlyExperiencesWithActiveResource</link>
      <description>Last updated 23:04 BST Fri 30 June.&lt;br /&gt;&amp;#8230;&lt;br /&gt;&lt;br /&gt;I made this changes to get a create function:&lt;br /&gt;&lt;br /&gt;[[ActiveResource::Base =&gt; http://dev.rubyonrails.org/browser/trunk/activeresource/lib/active_resource/base.rb#L65]]&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;def save&lt;br /&gt;    id ? update : create&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;def create&lt;br /&gt;  attributes[&quot;id&quot;] = connection.post(self.class.collection_path, to_xml)&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;[[ActiveResource::Base =&gt; http://dev.rubyonrails.org/browser/trunk/activeresource/lib/active_resource/base.rb#L54]]&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;def post(path, body)&lt;br /&gt;  response = request(:post, path, body)&lt;br /&gt;  return response['Location'][/\/([^\/]*?)$/,1] # The id&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&amp;#8230;&lt;br /&gt;Content was also deleted</description>
      <author>tamc2</author>
      <pubDate>Fri, 30 Jun 2006 22:04:20 +0000</pubDate>
    </item>
    <item>
      <title>Last updated 22:45 BST Fri 30 June.</title>
      <link>http://tom.counsell.org/view/EarlyExperiencesWithActiveResource</link>
      <description>Last updated 22:45 BST Fri 30 June.&lt;br /&gt;&amp;#8230;&lt;br /&gt;Content was also deleted</description>
      <author>tamc2</author>
      <pubDate>Fri, 30 Jun 2006 21:47:37 +0000</pubDate>
    </item>
    <item>
      <title>Last updated 22:45 BST Fri 30 June</title>
      <link>http://tom.counsell.org/view/EarlyExperiencesWithActiveResource</link>
      <description>Last updated 22:45 BST Fri 30 June&lt;br /&gt;&amp;#8230;&lt;br /&gt;h2. Put / Update&lt;br /&gt;&amp;#8230;&lt;br /&gt;&lt;br /&gt;h2. Post / Create&lt;br /&gt;&lt;br /&gt;Creating a record doesn't work, as @Person.save@ currently goes straight to the put method.&lt;br /&gt;&amp;#8230;&lt;br /&gt;Content was also deleted</description>
      <author>tamc2</author>
      <pubDate>Fri, 30 Jun 2006 21:45:29 +0000</pubDate>
    </item>
    <item>
      <title>h1. Early experiences with Active Resource</title>
      <link>http://tom.counsell.org/view/EarlyExperiencesWithActiveResource</link>
      <description>h1. Early experiences with Active Resource&lt;br /&gt;&lt;br /&gt;Last updated 22:05 BST Fri 30 June&lt;br /&gt;&lt;br /&gt;At the recent RailsConf David Heinemeier Hansson announced his ideas for an active resource library in [[rails =&gt; http://www.rubyonrails.com ]].  His slides are available [[ here =&gt; http://www.loudthinking.com/lt-files/worldofresources.pdf ]].&lt;br /&gt;&lt;br /&gt;Unfortunately the early version he checked into the [[ rails edge repository =&gt; http://dev.rubyonrails.org/browser/trunk/activeresource ]] doesn't quite match his slides.&lt;br /&gt;&lt;br /&gt;Below are my (in progress) notes on getting it to work.&lt;br /&gt;&lt;br /&gt;h2. Pre-requisites&lt;br /&gt;&lt;br /&gt;You need edge rails: @rake rails:freeze:edge@ &lt;br /&gt;&lt;br /&gt;You need some rest-ful type routes. I've used: @script/plugin install simply_restful@&lt;br /&gt;&lt;br /&gt;You need a controller that has the same name as your model (e.g. PeopleController) with index, new, create, show, edit, update and delete methods. Each of these needs to respond sensibly to xml requests, e.g.:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;  def show&lt;br /&gt;    @patch = Patch.find(params[:id])&lt;br /&gt;    respond_to do |format|&lt;br /&gt;      format.html&lt;br /&gt;      format.xml { render :xml =&gt; @patch.to_xml }&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;h2. Initialization&lt;br /&gt;&lt;br /&gt;The example that DHH gave:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Person = ActiveResource::Struct.new do |person|&lt;br /&gt;  person.uri = &quot;http://api.myremote.com/people&quot; &lt;br /&gt;  person.credentials :name =&gt; &quot;me&quot;, :password =&gt; &quot;password&quot; &lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;What works in the code:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Person = ActiveResource::Struct.create&lt;br /&gt;Person.site = &quot;http://api.myremote.com/people&quot; &lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;h2. Get&lt;br /&gt;&lt;br /&gt;You can then get the object, as expected:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;p = Person.find 1&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;h2. Put / Post / Update&lt;br /&gt;&lt;br /&gt;Saving doesn't work, because ActiveResource doesn't set the content-type. Adding this at the start of the request method in [[ActiveResource::Connection =&gt; http://dev.rubyonrails.org/browser/trunk/activeresource/lib/active_resource/connection.rb#L60]] seems to help:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;arguments &lt;&lt; { 'content-type' =&gt; 'application/xml' }&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&amp;#8230;&lt;br /&gt;Content was also deleted</description>
      <author>tamc2</author>
      <pubDate>Fri, 30 Jun 2006 21:44:33 +0000</pubDate>
    </item>
    <item>
      <title>content moved to [[]]</title>
      <link>http://tom.counsell.org/view/EarlyExperiencesWithActiveResource</link>
      <description>content moved to [[]]&lt;br /&gt;&amp;#8230;&lt;br /&gt;Content was also deleted</description>
      <author>tamc2</author>
      <pubDate>Fri, 30 Jun 2006 21:44:05 +0000</pubDate>
    </item>
    <item>
      <title>Last updated 22:05 BST Fri 30 June</title>
      <link>http://tom.counsell.org/view/EarlyExperiencesWithActiveResource</link>
      <description>Last updated 22:05 BST Fri 30 June&lt;br /&gt;&lt;br /&gt;&amp;#8230;&lt;br /&gt;&lt;br /&gt;h2. Pre-requisites&lt;br /&gt;&lt;br /&gt;You need edge rails: @rake rails:freeze:edge@ &lt;br /&gt;&lt;br /&gt;You need some rest-ful type routes. I've used: @script/plugin install simply_restful@&lt;br /&gt;&lt;br /&gt;You need a controller that has the same name as your model (e.g. PeopleController) with index, new, create, show, edit, update and delete methods. Each of these needs to respond sensibly to xml requests, e.g.:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;  def show&lt;br /&gt;    @patch = Patch.find(params[:id])&lt;br /&gt;    respond_to do |format|&lt;br /&gt;      format.html&lt;br /&gt;      format.xml { render :xml =&gt; @patch.to_xml }&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&amp;#8230;&lt;br /&gt;</description>
      <author>tamc2</author>
      <pubDate>Fri, 30 Jun 2006 21:07:43 +0000</pubDate>
    </item>
    <item>
      <title>Saving doesn't work, because ActiveResource doesn't set the content-type. Adding this at the start of the request method in [[ActiveResource::Connection =&gt; http://dev.rubyonrails.org/browser/trunk/activeresource/lib/active_resource/connection.rb#L60]] seems to help:</title>
      <link>http://tom.counsell.org/view/EarlyExperiencesWithActiveResource</link>
      <description>Saving doesn't work, because ActiveResource doesn't set the content-type. Adding this at the start of the request method in [[ActiveResource::Connection =&gt; http://dev.rubyonrails.org/browser/trunk/activeresource/lib/active_resource/connection.rb#L60]] seems to help:&lt;br /&gt;&amp;#8230;&lt;br /&gt;Content was also deleted</description>
      <author>tamc2</author>
      <pubDate>Fri, 30 Jun 2006 21:02:27 +0000</pubDate>
    </item>
    <item>
      <title>h2. Get</title>
      <link>http://tom.counsell.org/view/EarlyExperiencesWithActiveResource</link>
      <description>h2. Get&lt;br /&gt;&lt;br /&gt;&amp;#8230;&lt;br /&gt;&lt;br /&gt;h2. Put / Post / Update&lt;br /&gt;&amp;#8230;&lt;br /&gt;</description>
      <author>tamc2</author>
      <pubDate>Fri, 30 Jun 2006 21:01:54 +0000</pubDate>
    </item>
    <item>
      <title>h1. Early experiences with Active Resource</title>
      <link>http://tom.counsell.org/view/EarlyExperiencesWithActiveResource</link>
      <description>h1. Early experiences with Active Resource&lt;br /&gt;&lt;br /&gt;At the recent RailsConf David Heinemeier Hansson announced his ideas for an active resource library in [[rails =&gt; http://www.rubyonrails.com ]].  His slides are available [[ here =&gt; http://www.loudthinking.com/lt-files/worldofresources.pdf ]].&lt;br /&gt;&lt;br /&gt;Unfortunately the early version he checked into the [[ rails edge repository =&gt; http://dev.rubyonrails.org/browser/trunk/activeresource ]] doesn't quite match his slides.&lt;br /&gt;&lt;br /&gt;Below are my (in progress) notes on getting it to work.&lt;br /&gt;&lt;br /&gt;h2. Initialization&lt;br /&gt;&lt;br /&gt;The example that DHH gave:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Person = ActiveResource::Struct.new do |person|&lt;br /&gt;  person.uri = &quot;http://api.myremote.com/people&quot; &lt;br /&gt;  person.credentials :name =&gt; &quot;me&quot;, :password =&gt; &quot;password&quot; &lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;What works in the code:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Person = ActiveResource::Struct.create&lt;br /&gt;Person.site = &quot;http://api.myremote.com/people&quot; &lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;You can then get the object, as expected:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;p = Person.find 1&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Saving doesn't work, because ActiveResource doesn't set the content-type. Adding this at the start of the request method in [[ActiveResource::Connection =&gt; http://dev.rubyonrails.org/browser/trunk/activeresource/lib/active_resource/connection.rb]] seems to help:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;arguments &lt;&lt; { 'content-type' =&gt; 'application/xml' }&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&amp;#8230;&lt;br /&gt;</description>
      <author>tamc2</author>
      <pubDate>Fri, 30 Jun 2006 21:01:05 +0000</pubDate>
    </item>
    <textInput>
      <title>Search</title>
      <description>Search Tom Counsell's Soks Wiki's text</description>
      <name>regex</name>
      <link>http://tom.counsell.org/find/Searchpage</link>
    </textInput>
  </channel>
</rss>