<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>rails rest api activeresource on random thoughts</title><link>https://awesomeprogrammer.com/categories/rails-rest-api-activeresource/</link><description>Recent content in rails rest api activeresource on random thoughts</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Tue, 10 Dec 2013 00:00:00 +0000</lastBuildDate><atom:link href="https://awesomeprogrammer.com/categories/rails-rest-api-activeresource/index.xml" rel="self" type="application/rss+xml"/><item><title>REST API Client Server with Rails</title><link>https://awesomeprogrammer.com/blog/2013/12/10/rest-api-client-server-with-rails/</link><pubDate>Tue, 10 Dec 2013 00:00:00 +0000</pubDate><guid>https://awesomeprogrammer.com/blog/2013/12/10/rest-api-client-server-with-rails/</guid><description><![CDATA[<p>Few days ago a new project was thrown in my face ;). And it was interesting I must say - extracting some heavy internals of existing application into internal API + external client (app), that could be developed further with some additional features.</p>
<p>First I spend few hours do to some research an just to experiment a little, I found <a href="http://stackoverflow.com/questions/10941249/separate-rest-json-api-server-and-client">this topic</a> on stackoverflow (d&rsquo;oh) that was quite useful. Obviously first I though of some MV* Javascript framework at first, <a href="http://angularjs.org/">AngularJS</a> seemed like a great choice, but after messing with it for a while I concluded I won&rsquo;t be able to learn it in given time-frame I had (sorry Angular, maybe next time!). I decided to go more ruby (backend) way - my weapon of choice was: <a href="https://github.com/rails/activeresource/">Active Resource</a>.</p>
<p>ActiveResource was extracted into separate gem in Rails 4, and it basically allows you to route actions on you model to REST API. So you get almost all the benefits as using regular ActiveRecord model like associations, query methods etc. Sounds cool, right? So how to do it in few general steps:</p>
<ul>
<li>
<p>first you need to build your API, you may have some kind of existing API already in your app, you may even want to build even external API that will serve data on behalf of you app, there are so many different cases you wouldn&rsquo;t guess :). You can go with rails, with <a href="https://github.com/rails-api/rails-api">rails-api</a> or even something like [grape] (grape sound really cool if you want to build something light-weight from scratch).</p>
</li>
<li>
<p>you have to serialize your data at some point into pretty JSON - it depends on what you use, two popular choices are <a href="https://github.com/rails-api/active_model_serializers">active_model_serializers</a> and <a href="https://github.com/nesquena/rabl">rabl</a></p>
</li>
</ul>
<p>Now that you have basic API setup it&rsquo;s time to communicate with it. ActiveResource have very poor readme, but great RDoc (that&rsquo;s a shame, to be honest I prefer just having rock-solid readme file, but maybe that&rsquo;s just me :P). Few tips you might find useful:</p>
<h3 id="how-to-modify-activeresource-headers">How to modify ActiveResource headers?</h3>
<p>Let&rsquo;s say you want to authenticate by checking <code>HTTP_SECRET</code> header, so let&rsquo;s create a base class that all of your ActiveResource models will inherit from.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-ruby" data-lang="ruby"><span style="display:flex;"><span><span style="color:#66d9ef">class</span> <span style="color:#a6e22e">Base</span> <span style="color:#f92672">&lt;</span> <span style="color:#66d9ef">ActiveResource</span><span style="color:#f92672">::</span><span style="color:#66d9ef">Base</span>
</span></span><span style="display:flex;"><span>  self<span style="color:#f92672">.</span>headers<span style="color:#f92672">[</span><span style="color:#e6db74">&#39;SECRET&#39;</span><span style="color:#f92672">]</span> <span style="color:#f92672">=</span> <span style="color:#e6db74">&#39;wow, so secret, wow&#39;</span> <span style="color:#75715e"># notice no HTTP_ here</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">end</span>
</span></span></code></pre></div><p>See why this works - <a href="https://github.com/rails/activeresource/blob/master/lib/active_resource/base.rb#L606">source</a>.</p>
<h3 id="how-to-paginate-with-activeresource">How to paginate with ActiveResource?</h3>
<p>You can go with not so restful way by using <code>ActiveResource::Collection</code>. See <a href="https://gist.github.com/emq/7838240">this gist</a> I stolen <a href="http://yetimedia.tumblr.com/post/35233051627/activeresource-is-dead-long-live-activeresource">this blogpost</a> (check this out, it&rsquo;s very useful &lt;3). Or you can use <a href="https://github.com/Fivell/activeresource-response">activeresource-response</a> that have <a href="https://github.com/Fivell/activeresource-response#full-example-of-usage-with-kaminari-gem">full working example</a> how to implement REST pagination with kaminari. It&rsquo;s that simple. In case you are using will_paginate on your API side, this should help a little:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-ruby" data-lang="ruby"><span style="display:flex;"><span>  <span style="color:#75715e"># Kaminari</span>
</span></span><span style="display:flex;"><span>  response<span style="color:#f92672">.</span>headers<span style="color:#f92672">[</span><span style="color:#e6db74">&#34;X-total&#34;</span><span style="color:#f92672">]</span> <span style="color:#f92672">=</span> @orders<span style="color:#f92672">.</span>total_count<span style="color:#f92672">.</span>to_s
</span></span><span style="display:flex;"><span>  response<span style="color:#f92672">.</span>headers<span style="color:#f92672">[</span><span style="color:#e6db74">&#34;X-offset&#34;</span><span style="color:#f92672">]</span> <span style="color:#f92672">=</span> @orders<span style="color:#f92672">.</span>offset_value<span style="color:#f92672">.</span>to_s
</span></span><span style="display:flex;"><span>  response<span style="color:#f92672">.</span>headers<span style="color:#f92672">[</span><span style="color:#e6db74">&#34;X-limit&#34;</span><span style="color:#f92672">]</span> <span style="color:#f92672">=</span> @orders<span style="color:#f92672">.</span>limit_value<span style="color:#f92672">.</span>to_s
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e"># Will_paginate</span>
</span></span><span style="display:flex;"><span>  response<span style="color:#f92672">.</span>headers<span style="color:#f92672">[</span><span style="color:#e6db74">&#34;X-total&#34;</span><span style="color:#f92672">]</span> <span style="color:#f92672">=</span> @orders<span style="color:#f92672">.</span>total_entries<span style="color:#f92672">.</span>to_s
</span></span><span style="display:flex;"><span>  response<span style="color:#f92672">.</span>headers<span style="color:#f92672">[</span><span style="color:#e6db74">&#34;X-offset&#34;</span><span style="color:#f92672">]</span> <span style="color:#f92672">=</span> @orders<span style="color:#f92672">.</span>offset<span style="color:#f92672">.</span>to_s
</span></span><span style="display:flex;"><span>  response<span style="color:#f92672">.</span>headers<span style="color:#f92672">[</span><span style="color:#e6db74">&#34;X-limit&#34;</span><span style="color:#f92672">]</span> <span style="color:#f92672">=</span> @orders<span style="color:#f92672">.</span>per_page<span style="color:#f92672">.</span>to_s
</span></span></code></pre></div><p>On the API side you might also use will_paginate, in that case you can just require <code>will_paginate/array</code> (in initializer for example) and paginate array directly by calling <code>.paginate(options)</code> with proper total/page/per_page values - <a href="https://github.com/mislav/will_paginate/blob/master/lib/will_paginate/array.rb">see source</a>.</p>
<h3 id="how-to-handle-remote-validation">How to handle remote validation?</h3>
<p>You probably don&rsquo;t want to duplicate validation logic in both API server and the client. So it makes sense to just return validation errors to ActiveResource in a way it can understand it. It should be enough to respond with status 422 (ActiveResource::ResourceInvalid) and pass validation errors:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-ruby" data-lang="ruby"><span style="display:flex;"><span><span style="color:#75715e"># Inside API try to save/update_attributes and on failure return this:</span>
</span></span><span style="display:flex;"><span>render <span style="color:#e6db74">json</span>: { <span style="color:#e6db74">errors</span>: object<span style="color:#f92672">.</span>errors }, <span style="color:#e6db74">status</span>: <span style="color:#ae81ff">422</span>
</span></span></code></pre></div><h3 id="testing--mocks">Testing &amp; mocks</h3>
<p>ActiveResource provides HttpMock class, that allows you to register mock responses. Taken from docs:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-ruby" data-lang="ruby"><span style="display:flex;"><span><span style="color:#75715e"># unfortunately can&#39;t register regex path at the moment (4.0.0)</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">ActiveResource</span><span style="color:#f92672">::</span><span style="color:#66d9ef">HttpMock</span><span style="color:#f92672">.</span>respond_to <span style="color:#66d9ef">do</span> <span style="color:#f92672">|</span>mock<span style="color:#f92672">|</span>
</span></span><span style="display:flex;"><span>  mock<span style="color:#f92672">.</span>post <span style="color:#e6db74">&#34;/people.json&#34;</span>, {}, @matz, <span style="color:#ae81ff">201</span>, <span style="color:#e6db74">&#34;Location&#34;</span> <span style="color:#f92672">=&gt;</span> <span style="color:#e6db74">&#34;/people/1.json&#34;</span>
</span></span><span style="display:flex;"><span>  mock<span style="color:#f92672">.</span>get <span style="color:#e6db74">&#34;/people/1.json&#34;</span>, {}, @matz
</span></span><span style="display:flex;"><span>  mock<span style="color:#f92672">.</span>put <span style="color:#e6db74">&#34;/people/1.json&#34;</span>, {}, <span style="color:#66d9ef">nil</span>, <span style="color:#ae81ff">204</span>
</span></span><span style="display:flex;"><span>  mock<span style="color:#f92672">.</span>delete <span style="color:#e6db74">&#34;/people/1.json&#34;</span>, {}, <span style="color:#66d9ef">nil</span>, <span style="color:#ae81ff">200</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">end</span>
</span></span></code></pre></div><p>You can clear defined request by calling <code>ActiveResource::HttpMock.reset!</code>. If you want to raise an error, you can trigger it by setting proper response code. Once again, taken from docs:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-ruby" data-lang="ruby"><span style="display:flex;"><span>  <span style="color:#75715e"># * 200..399 - Valid response. No exceptions, other than these redirects:</span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e"># * 301, 302, 303, 307 - ActiveResource::Redirection</span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e"># * 400 - ActiveResource::BadRequest</span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e"># * 401 - ActiveResource::UnauthorizedAccess</span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e"># * 403 - ActiveResource::ForbiddenAccess</span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e"># * 404 - ActiveResource::ResourceNotFound</span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e"># * 405 - ActiveResource::MethodNotAllowed</span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e"># * 409 - ActiveResource::ResourceConflict</span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e"># * 410 - ActiveResource::ResourceGone</span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e"># * 422 - ActiveResource::ResourceInvalid (rescued by save as validation errors)</span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e"># * 401..499 - ActiveResource::ClientError</span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e"># * 500..599 - ActiveResource::ServerError</span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e"># * Other - ActiveResource::ConnectionError</span>
</span></span></code></pre></div><p>Happy coding!</p>]]></description><content:encoded><![CDATA[<p>Few days ago a new project was thrown in my face ;). And it was interesting I must say - extracting some heavy internals of existing application into internal API + external client (app), that could be developed further with some additional features.</p>
<p>First I spend few hours do to some research an just to experiment a little, I found <a href="http://stackoverflow.com/questions/10941249/separate-rest-json-api-server-and-client">this topic</a> on stackoverflow (d&rsquo;oh) that was quite useful. Obviously first I though of some MV* Javascript framework at first, <a href="http://angularjs.org/">AngularJS</a> seemed like a great choice, but after messing with it for a while I concluded I won&rsquo;t be able to learn it in given time-frame I had (sorry Angular, maybe next time!). I decided to go more ruby (backend) way - my weapon of choice was: <a href="https://github.com/rails/activeresource/">Active Resource</a>.</p>
<p>ActiveResource was extracted into separate gem in Rails 4, and it basically allows you to route actions on you model to REST API. So you get almost all the benefits as using regular ActiveRecord model like associations, query methods etc. Sounds cool, right? So how to do it in few general steps:</p>
<ul>
<li>
<p>first you need to build your API, you may have some kind of existing API already in your app, you may even want to build even external API that will serve data on behalf of you app, there are so many different cases you wouldn&rsquo;t guess :). You can go with rails, with <a href="https://github.com/rails-api/rails-api">rails-api</a> or even something like [grape] (grape sound really cool if you want to build something light-weight from scratch).</p>
</li>
<li>
<p>you have to serialize your data at some point into pretty JSON - it depends on what you use, two popular choices are <a href="https://github.com/rails-api/active_model_serializers">active_model_serializers</a> and <a href="https://github.com/nesquena/rabl">rabl</a></p>
</li>
</ul>
<p>Now that you have basic API setup it&rsquo;s time to communicate with it. ActiveResource have very poor readme, but great RDoc (that&rsquo;s a shame, to be honest I prefer just having rock-solid readme file, but maybe that&rsquo;s just me :P). Few tips you might find useful:</p>
<h3 id="how-to-modify-activeresource-headers">How to modify ActiveResource headers?</h3>
<p>Let&rsquo;s say you want to authenticate by checking <code>HTTP_SECRET</code> header, so let&rsquo;s create a base class that all of your ActiveResource models will inherit from.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-ruby" data-lang="ruby"><span style="display:flex;"><span><span style="color:#66d9ef">class</span> <span style="color:#a6e22e">Base</span> <span style="color:#f92672">&lt;</span> <span style="color:#66d9ef">ActiveResource</span><span style="color:#f92672">::</span><span style="color:#66d9ef">Base</span>
</span></span><span style="display:flex;"><span>  self<span style="color:#f92672">.</span>headers<span style="color:#f92672">[</span><span style="color:#e6db74">&#39;SECRET&#39;</span><span style="color:#f92672">]</span> <span style="color:#f92672">=</span> <span style="color:#e6db74">&#39;wow, so secret, wow&#39;</span> <span style="color:#75715e"># notice no HTTP_ here</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">end</span>
</span></span></code></pre></div><p>See why this works - <a href="https://github.com/rails/activeresource/blob/master/lib/active_resource/base.rb#L606">source</a>.</p>
<h3 id="how-to-paginate-with-activeresource">How to paginate with ActiveResource?</h3>
<p>You can go with not so restful way by using <code>ActiveResource::Collection</code>. See <a href="https://gist.github.com/emq/7838240">this gist</a> I stolen <a href="http://yetimedia.tumblr.com/post/35233051627/activeresource-is-dead-long-live-activeresource">this blogpost</a> (check this out, it&rsquo;s very useful &lt;3). Or you can use <a href="https://github.com/Fivell/activeresource-response">activeresource-response</a> that have <a href="https://github.com/Fivell/activeresource-response#full-example-of-usage-with-kaminari-gem">full working example</a> how to implement REST pagination with kaminari. It&rsquo;s that simple. In case you are using will_paginate on your API side, this should help a little:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-ruby" data-lang="ruby"><span style="display:flex;"><span>  <span style="color:#75715e"># Kaminari</span>
</span></span><span style="display:flex;"><span>  response<span style="color:#f92672">.</span>headers<span style="color:#f92672">[</span><span style="color:#e6db74">&#34;X-total&#34;</span><span style="color:#f92672">]</span> <span style="color:#f92672">=</span> @orders<span style="color:#f92672">.</span>total_count<span style="color:#f92672">.</span>to_s
</span></span><span style="display:flex;"><span>  response<span style="color:#f92672">.</span>headers<span style="color:#f92672">[</span><span style="color:#e6db74">&#34;X-offset&#34;</span><span style="color:#f92672">]</span> <span style="color:#f92672">=</span> @orders<span style="color:#f92672">.</span>offset_value<span style="color:#f92672">.</span>to_s
</span></span><span style="display:flex;"><span>  response<span style="color:#f92672">.</span>headers<span style="color:#f92672">[</span><span style="color:#e6db74">&#34;X-limit&#34;</span><span style="color:#f92672">]</span> <span style="color:#f92672">=</span> @orders<span style="color:#f92672">.</span>limit_value<span style="color:#f92672">.</span>to_s
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e"># Will_paginate</span>
</span></span><span style="display:flex;"><span>  response<span style="color:#f92672">.</span>headers<span style="color:#f92672">[</span><span style="color:#e6db74">&#34;X-total&#34;</span><span style="color:#f92672">]</span> <span style="color:#f92672">=</span> @orders<span style="color:#f92672">.</span>total_entries<span style="color:#f92672">.</span>to_s
</span></span><span style="display:flex;"><span>  response<span style="color:#f92672">.</span>headers<span style="color:#f92672">[</span><span style="color:#e6db74">&#34;X-offset&#34;</span><span style="color:#f92672">]</span> <span style="color:#f92672">=</span> @orders<span style="color:#f92672">.</span>offset<span style="color:#f92672">.</span>to_s
</span></span><span style="display:flex;"><span>  response<span style="color:#f92672">.</span>headers<span style="color:#f92672">[</span><span style="color:#e6db74">&#34;X-limit&#34;</span><span style="color:#f92672">]</span> <span style="color:#f92672">=</span> @orders<span style="color:#f92672">.</span>per_page<span style="color:#f92672">.</span>to_s
</span></span></code></pre></div><p>On the API side you might also use will_paginate, in that case you can just require <code>will_paginate/array</code> (in initializer for example) and paginate array directly by calling <code>.paginate(options)</code> with proper total/page/per_page values - <a href="https://github.com/mislav/will_paginate/blob/master/lib/will_paginate/array.rb">see source</a>.</p>
<h3 id="how-to-handle-remote-validation">How to handle remote validation?</h3>
<p>You probably don&rsquo;t want to duplicate validation logic in both API server and the client. So it makes sense to just return validation errors to ActiveResource in a way it can understand it. It should be enough to respond with status 422 (ActiveResource::ResourceInvalid) and pass validation errors:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-ruby" data-lang="ruby"><span style="display:flex;"><span><span style="color:#75715e"># Inside API try to save/update_attributes and on failure return this:</span>
</span></span><span style="display:flex;"><span>render <span style="color:#e6db74">json</span>: { <span style="color:#e6db74">errors</span>: object<span style="color:#f92672">.</span>errors }, <span style="color:#e6db74">status</span>: <span style="color:#ae81ff">422</span>
</span></span></code></pre></div><h3 id="testing--mocks">Testing &amp; mocks</h3>
<p>ActiveResource provides HttpMock class, that allows you to register mock responses. Taken from docs:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-ruby" data-lang="ruby"><span style="display:flex;"><span><span style="color:#75715e"># unfortunately can&#39;t register regex path at the moment (4.0.0)</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">ActiveResource</span><span style="color:#f92672">::</span><span style="color:#66d9ef">HttpMock</span><span style="color:#f92672">.</span>respond_to <span style="color:#66d9ef">do</span> <span style="color:#f92672">|</span>mock<span style="color:#f92672">|</span>
</span></span><span style="display:flex;"><span>  mock<span style="color:#f92672">.</span>post <span style="color:#e6db74">&#34;/people.json&#34;</span>, {}, @matz, <span style="color:#ae81ff">201</span>, <span style="color:#e6db74">&#34;Location&#34;</span> <span style="color:#f92672">=&gt;</span> <span style="color:#e6db74">&#34;/people/1.json&#34;</span>
</span></span><span style="display:flex;"><span>  mock<span style="color:#f92672">.</span>get <span style="color:#e6db74">&#34;/people/1.json&#34;</span>, {}, @matz
</span></span><span style="display:flex;"><span>  mock<span style="color:#f92672">.</span>put <span style="color:#e6db74">&#34;/people/1.json&#34;</span>, {}, <span style="color:#66d9ef">nil</span>, <span style="color:#ae81ff">204</span>
</span></span><span style="display:flex;"><span>  mock<span style="color:#f92672">.</span>delete <span style="color:#e6db74">&#34;/people/1.json&#34;</span>, {}, <span style="color:#66d9ef">nil</span>, <span style="color:#ae81ff">200</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">end</span>
</span></span></code></pre></div><p>You can clear defined request by calling <code>ActiveResource::HttpMock.reset!</code>. If you want to raise an error, you can trigger it by setting proper response code. Once again, taken from docs:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-ruby" data-lang="ruby"><span style="display:flex;"><span>  <span style="color:#75715e"># * 200..399 - Valid response. No exceptions, other than these redirects:</span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e"># * 301, 302, 303, 307 - ActiveResource::Redirection</span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e"># * 400 - ActiveResource::BadRequest</span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e"># * 401 - ActiveResource::UnauthorizedAccess</span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e"># * 403 - ActiveResource::ForbiddenAccess</span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e"># * 404 - ActiveResource::ResourceNotFound</span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e"># * 405 - ActiveResource::MethodNotAllowed</span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e"># * 409 - ActiveResource::ResourceConflict</span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e"># * 410 - ActiveResource::ResourceGone</span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e"># * 422 - ActiveResource::ResourceInvalid (rescued by save as validation errors)</span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e"># * 401..499 - ActiveResource::ClientError</span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e"># * 500..599 - ActiveResource::ServerError</span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e"># * Other - ActiveResource::ConnectionError</span>
</span></span></code></pre></div><p>Happy coding!</p>]]></content:encoded></item></channel></rss>