<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Pablo&#039;s blog &#187; Rails</title>
	<atom:link href="http://pupeno.com/tag/rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://pupeno.com</link>
	<description>A bit of this, a bit of that and a lot about computers</description>
	<lastBuildDate>Wed, 15 Feb 2012 08:39:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='pupeno.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/57ca76f9fb1bf9d10a9dd732ea88cc57?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Pablo&#039;s blog &#187; Rails</title>
		<link>http://pupeno.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://pupeno.com/osd.xml" title="Pablo&#039;s blog" />
	<atom:link rel='hub' href='http://pupeno.com/?pushpress=hub'/>
		<item>
		<title>Better assert difference?</title>
		<link>http://pupeno.com/2010/09/15/better-assert-difference/</link>
		<comments>http://pupeno.com/2010/09/15/better-assert-difference/#comments</comments>
		<pubDate>Wed, 15 Sep 2010 05:47:39 +0000</pubDate>
		<dc:creator>Pablo</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[assert_difference]]></category>
		<category><![CDATA[idea]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://pupeno.com/?p=1831</guid>
		<description><![CDATA[Rails come with some awesome assertion methods for writing tests: assert_difference("User.count", +1) do create_a_user end That asserts that the count of user was incremented by one. The plus sign is not needed, that&#8217;s just an integer, I add it to make things clear. You can mix several of this expressions into one assert_difference: assert_difference(["User.count", "Profile.count"], [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pupeno.com&amp;blog=8470507&amp;post=1831&amp;subd=pupeno&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Rails come with some awesome assertion methods for writing tests:</p>
<pre>
assert_difference("User.count", +1) do
  create_a_user
end
</pre>
<p>That asserts that the count of user was incremented by one. The plus sign is not needed, that&#8217;s just an integer, I add it to make things clear. You can mix several of this expressions into one assert_difference:</p>
<pre>
assert_difference(["User.count", "Profile.count"], +1) do
  create_a_user
end
</pre>
<p>That works as expected, it asserts that both users and profiles were incremented by one. The problem I have is that I often found myself doing this:</p>
<pre>
assert_difference "User.count", +1 do
  assert_difference "Admin.count", 0 do
    assert_difference "Message.count", +3 do  # We send three welcome messages to each user, like Gmail.
      create_a_user
    end
  end
end
</pre>
<p>That looks ugly. Let&#8217;s try something different:</p>
<pre>
assert_difference("User.count" =&gt; +1, "Admin.count" =&gt; 0, "Message.count" =&gt; +3) do
  create_a_user
end
</pre>
<p>Well, that looks nicer, and straightforward, so I implemented it (starting from <a href="http://github.com/rails/rails/blob/5f5c508444fd4368e51fe5dbf287be13d03a8d0d/activesupport/lib/active_support/testing/assertions.rb#L37">Rails 3 assert_difference</a>):</p>
<pre>
def assert_difference(expressions, difference = 1, message = nil, &amp;block)
  b = block.send(:binding)
  if !expressions.is_a? Hash
    exps = Array.wrap(expressions)
    expressions = {}
    exps.each { |e| expressions[e] = difference }
  end

  before = {}
  expressions.each {|exp, _| before[exp] = eval(exp, b)}

  yield

  expressions.each do |exp, diff|
    error = "#{exp.inspect} didn't change by #{diff}"
    error = "#{message}.\n#{error}" if message
    assert_equal(before[exp] + diff, eval(exp, b), error)
  end
end
</pre>
<p>Do you like it? If you do, let me know and I might turn this into a patch for Rails 3 (and then let <em>them</em> now, otherwise they&#8217;ll ignore it).</p>
<p><strong>Update</strong>: <a href="/blog/sharing-my-code">this is now a gem</a>.</p>
<br />Filed under: <a href='http://pupeno.com/category/technical/'>Technical</a> Tagged: <a href='http://pupeno.com/tag/assert_difference/'>assert_difference</a>, <a href='http://pupeno.com/tag/idea/'>idea</a>, <a href='http://pupeno.com/tag/rails/'>Rails</a>, <a href='http://pupeno.com/tag/ruby-on-rails/'>Ruby on Rails</a>, <a href='http://pupeno.com/tag/testing/'>testing</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pupeno.wordpress.com/1831/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pupeno.wordpress.com/1831/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pupeno.wordpress.com/1831/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pupeno.wordpress.com/1831/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pupeno.wordpress.com/1831/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pupeno.wordpress.com/1831/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pupeno.wordpress.com/1831/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pupeno.wordpress.com/1831/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pupeno.wordpress.com/1831/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pupeno.wordpress.com/1831/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pupeno.wordpress.com/1831/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pupeno.wordpress.com/1831/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pupeno.wordpress.com/1831/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pupeno.wordpress.com/1831/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pupeno.com&amp;blog=8470507&amp;post=1831&amp;subd=pupeno&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pupeno.com/2010/09/15/better-assert-difference/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/931970b8dc51b72e05e3a12b88612d61?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">Pablo</media:title>
		</media:content>
	</item>
		<item>
		<title>Redirect to SSL in Rails applications</title>
		<link>http://pupeno.com/2010/09/14/redirect-to-ssl-in-rails-applications/</link>
		<comments>http://pupeno.com/2010/09/14/redirect-to-ssl-in-rails-applications/#comments</comments>
		<pubDate>Tue, 14 Sep 2010 05:31:43 +0000</pubDate>
		<dc:creator>Pablo</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[SSL]]></category>

		<guid isPermaLink="false">http://pupeno.com/?p=1818</guid>
		<description><![CDATA[I&#8217;ve looked at the various ssl_requirement repositories out there. I concluded the most modern and maintained version is yardstick&#8217;s which is released as a gem called sslrequirement, but I&#8217;ve failed to use it properly. So I just did it by hand. First, we need a simple method that will let us know whether SSL is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pupeno.com&amp;blog=8470507&amp;post=1818&amp;subd=pupeno&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve looked at the <a href="http://github.com/yardstick/ssl_requirement/network">various ssl_requirement</a> repositories out there. I concluded the most modern and maintained version is <a href="http://github.com/yardstick/ssl_requirement">yardstick&#8217;s</a> which is released as a gem called <a href="https://rubygems.org/gems/sslrequirement">sslrequirement</a>, but I&#8217;ve failed to use it properly. So I just did it by hand.</p>
<p>First, we need a simple method that will let us know whether SSL is enabled or not. We don&#8217;t want to redirect to SSL in development mode because it&#8217;ll fail. In the application controller I&#8217;ve created:</p>
<pre>
  def ssl_enabled?
    !(Rails.env.development? || Rails.env.test?)
  end
</pre>
<p>Switching to SSL is not only a matter of redirecting. If you show a login or signup form in your homepage, like I do in <a href="http://restraq.com">Restraq</a>, you want that to point to https even if the page was loaded as http. So I&#8217;ve added this helper method in the application controller:</p>
<pre>
  def https
    ssl_enabled? ? "https://" : "http://"
  end
  helper_method :https
</pre>
<p>and then for the forms I just do this:</p>
<pre>
form_for ..., :url =&gt; session_url(resource_name, :protocol =&gt; https)
</pre>
<p>and</p>
<pre>
form_for ..., :url =&gt; registration_url(resource_name, :protocol =&gt; https)
</pre>
<p>And then the redirection part, which is a before filter in the application controller because I want to redirect when hitting Devise controllers:</p>
<pre>
  def enforce_ssl_if_needed
    if request.protocol == "http://" &amp;&amp; ssl_enabled? &amp;&amp;
            (controller_name == "registrations" || controller_name == "sessions")
      redirect_to :protocol =&gt; https
    end
    return true
  end
</pre>
<p>and that&#8217;s it. I&#8217;m not actually testing it yet. For a similar solution with tests you might want to check out <a href="http://www.sslshopper.com/article-ruby-on-rails-ssl-configuration.html">SSLShopper&#8217;s article about this</a>.</p>
<br />Filed under: <a href='http://pupeno.com/category/technical/'>Technical</a> Tagged: <a href='http://pupeno.com/tag/rails/'>Rails</a>, <a href='http://pupeno.com/tag/ruby-on-rails/'>Ruby on Rails</a>, <a href='http://pupeno.com/tag/ssl/'>SSL</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pupeno.wordpress.com/1818/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pupeno.wordpress.com/1818/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pupeno.wordpress.com/1818/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pupeno.wordpress.com/1818/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pupeno.wordpress.com/1818/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pupeno.wordpress.com/1818/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pupeno.wordpress.com/1818/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pupeno.wordpress.com/1818/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pupeno.wordpress.com/1818/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pupeno.wordpress.com/1818/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pupeno.wordpress.com/1818/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pupeno.wordpress.com/1818/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pupeno.wordpress.com/1818/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pupeno.wordpress.com/1818/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pupeno.com&amp;blog=8470507&amp;post=1818&amp;subd=pupeno&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pupeno.com/2010/09/14/redirect-to-ssl-in-rails-applications/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/931970b8dc51b72e05e3a12b88612d61?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">Pablo</media:title>
		</media:content>
	</item>
		<item>
		<title>Really resetting the database</title>
		<link>http://pupeno.com/2010/05/08/really-resetting-the-database/</link>
		<comments>http://pupeno.com/2010/05/08/really-resetting-the-database/#comments</comments>
		<pubDate>Sat, 08 May 2010 11:03:57 +0000</pubDate>
		<dc:creator>Pablo</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[migrations]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[rake]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://pupeno.com/?p=1668</guid>
		<description><![CDATA[When I start coding a Ruby on Rails project, I find myself modifying the migration files over and over. I know this is not the way they were intended to use, but to avoid upfront design, I only ad fields when I need them. If I respected the way migrations were intended I would end [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pupeno.com&amp;blog=8470507&amp;post=1668&amp;subd=pupeno&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When I start coding a Ruby on Rails project, I find myself modifying the migration files over and over. I know this is not the way they were intended to use, but to avoid upfront design, I only ad fields when I need them. If I respected the way migrations were intended I would end up with hundred of migrations the first day and I would waste half my day just creating migrations.</p>
<p>After a project is deployed or a second developer is working on it, I revert to the way migrations are intended and I create a new one every time there&#8217;s a change I need in the database.</p>
<p>As migrations are intended to run only once, if you modify them, they won&#8217;t get run; and if you force them to run them, they&#8217;ll fail, because the database already contains such a table. So I&#8217;ve found myself doing this quite often:</p>
<pre>rake db:drop &amp;&amp; rake db:create &amp;&amp; rake db:migrate &amp;&amp; rake db:seed &amp;&amp; rake db:data</pre>
<p>db:data is a task I created to generate some sample data. Good known data that I can use to test the site locally. I&#8217;m using Factory Girl to create it, which I also use for the tests so I can re-use as much data creating logic as possible. It&#8217;s very good to get to a known state of the project you are developing and to get other developers started right away. I really recommend everyone doing it.</p>
<p>The problem is that I also need to reset my test data, so I end up having this other command and it gets horrible:</p>
<pre>RAILS_ENV=test rake db:drop &amp;&amp; RAILS_ENV=test rake db:create &amp;&amp; RAILS_ENV=test rake db:migrate &amp;&amp; RAILS_ENV=test rake db:seed</pre>
<p>Note: no db:data this time.</p>
<p>I&#8217;ve got tired of re-writing these commands or trying to find them in my bash history, so I decided to write a Ruby task that will do it for me and here it is in case you want to use it too:</p>
<pre>namespace :db do
  desc "Crush and burn the database"
  task :hard_reset =&gt; :environment do
    File.delete("db/schema.rb")
    Rake::Task["db:drop"].execute
    Rake::Task["db:create"].execute
    Rake::Task["db:migrate"].execute
    Rake::Task["db:seed"].execute
    if !Rails.env.test?
      Rake::Task["db:data"].execute
    end
  end

  desc "Generate sample data for developing"
  task :data =&gt; :environment do
    # Create the sample data in here
  end
end</pre>
<p>Enjoy!</p>
<p><strong>Update</strong>: To delete all records without resetting the whole database, check my post <a href="/blog/deleting-all-records-in-a-rails-project/">Deleting all records in a Rails project</a>.</p>
<br />Filed under: <a href='http://pupeno.com/category/technical/'>Technical</a> Tagged: <a href='http://pupeno.com/tag/database/'>database</a>, <a href='http://pupeno.com/tag/migrations/'>migrations</a>, <a href='http://pupeno.com/tag/rails/'>Rails</a>, <a href='http://pupeno.com/tag/rake/'>rake</a>, <a href='http://pupeno.com/tag/ruby/'>Ruby</a>, <a href='http://pupeno.com/tag/ruby-on-rails/'>Ruby on Rails</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pupeno.wordpress.com/1668/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pupeno.wordpress.com/1668/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pupeno.wordpress.com/1668/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pupeno.wordpress.com/1668/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pupeno.wordpress.com/1668/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pupeno.wordpress.com/1668/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pupeno.wordpress.com/1668/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pupeno.wordpress.com/1668/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pupeno.wordpress.com/1668/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pupeno.wordpress.com/1668/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pupeno.wordpress.com/1668/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pupeno.wordpress.com/1668/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pupeno.wordpress.com/1668/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pupeno.wordpress.com/1668/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pupeno.com&amp;blog=8470507&amp;post=1668&amp;subd=pupeno&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pupeno.com/2010/05/08/really-resetting-the-database/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/931970b8dc51b72e05e3a12b88612d61?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">Pablo</media:title>
		</media:content>
	</item>
		<item>
		<title>My Profile page: a RESTful single resource using Formtastic</title>
		<link>http://pupeno.com/2009/11/22/my-profile-page-a-restful-single-resource-using-formtastic/</link>
		<comments>http://pupeno.com/2009/11/22/my-profile-page-a-restful-single-resource-using-formtastic/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 13:49:52 +0000</pubDate>
		<dc:creator>Pablo</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[building Sano]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Sano]]></category>

		<guid isPermaLink="false">http://pupeno.com/?p=1392</guid>
		<description><![CDATA[I&#8217;ve just implemented the My Profile tab for Sano: Can I write 500 words about? Well, I can try. I like using RESTful routes. In case you don&#8217;t know what they are let me try to explain it quick, at least the relevant part. You normally have a set of route rules that would point [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pupeno.com&amp;blog=8470507&amp;post=1392&amp;subd=pupeno&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just implemented the My Profile tab for <a href="http://sano.pupeno.com">Sano</a>:</p>
<p><img class="alignnone size-full wp-image-1393" src="http://pupeno.files.wordpress.com/2009/11/sano-0186.png?w=538" alt="sano-018"   /></p>
<p>Can I write 500 words about? Well, I can try.</p>
<p>I like using RESTful routes. In case you don&#8217;t know what they are let me try to explain it quick, at least the relevant part. You normally have a set of route rules that would point /movies to the movie listing, /movies/new to a form to add a new movie, /movies/123 to see the movie 123. With RESTful routes in Rails all that is done automatic in a single line:</p>
<pre>map.resources :movies</pre>
<p>What you are doing is defining a resource. The resource has several actions that can be performed on them:</p>
<ul>
<li>index (a.k.a.: listing)</li>
<li>new</li>
<li>edit</li>
<li>create</li>
<li>update</li>
<li>destroy</li>
</ul>
<p>In Sano I have a weights resource that is a very fine example of it:</p>
<pre>map.resources :weights</pre>
<p>Running the rake routes command we can see all the routes it generate:</p>
<pre>    weights GET    /weights(.:format)          {:action=&gt;"index", :controller=&gt;"weights"}
            POST   /weights(.:format)          {:action=&gt;"create", :controller=&gt;"weights"}
 new_weight GET    /weights/new(.:format)      {:action=&gt;"new", :controller=&gt;"weights"}
edit_weight GET    /weights/:id/edit(.:format) {:action=&gt;"edit", :controller=&gt;"weights"}
     weight GET    /weights/:id(.:format)      {:action=&gt;"show", :controller=&gt;"weights"}
            PUT    /weights/:id(.:format)      {:action=&gt;"update", :controller=&gt;"weights"}
            DELETE /weights/:id(.:format)      {:action=&gt;"destroy", :controller=&gt;"weights"}</pre>
<p>You see the (.:format) in there? That means that every route is also accessible in alternative formats. For example: xml. Go and try it, add some weights and access <a href="http://sano.pupeno.com/weights.xml">http://sano.pupeno.com/weights.xml</a>.</p>
<p>If you are curious, the code for that is this:</p>
<pre>def index
  @weights = user.weights.all

  respond_to do |format|
    format.html
    format.xml  { render :xml =&gt; @weights }
  end
end</pre>
<p>I now want everything to be a resource. How can &#8220;my profile&#8221; be a resource? Well, it&#8217;s not hard. It&#8217;s not a collection resource, it&#8217;s a single resource. There&#8217;s no list of profiles, no creation of new profiles or destruction of profiles. There&#8217;s only editing and updating of a single profile (which is actually your user).</p>
<p>It turns out that in <a href="/tag/ruby-on-rails">Rails</a>, that&#8217;s very easy to define:</p>
<pre>map.resource :profile, :only =&gt; [:edit, :update]</pre>
<p>Notice how it says &#8220;resource&#8221; instead of &#8220;resources&#8221; and it only allows certain actions. Rails is really quite flexible here, logging in is also a resource. It&#8217;s called session and you can create them, by logging in, or destroy them, by logging out (no editing). There&#8217;s also an extra action needed by OpenID. This is the route definition:</p>
<pre>map.resource :session, :only =&gt; [:new, :create, :destroy], :member =&gt; { :finish_creating =&gt; :get }</pre>
<p>The &#8220;member&#8221; part specifies that action to be only for items, not for the whole collection. If it was a collection resource, you could have extra listings. The same way you have index, you could have sorted_index.</p>
<p>The form in the my-profile-page is an example of what Formtastic is good at. This is the whole form:</p>
<pre>&lt;% semantic_form_for @user, :url =&gt; profile_url do |f| %&gt;
  &lt;% f.inputs do -%&gt;
    &lt;%= f.input :name %&gt;
    &lt;%= f.input :email %&gt;
    &lt;%= f.input :height, :hint =&gt; "meters" %&gt;
    &lt;%= f.input :gender, :as =&gt; :radio, :collection =&gt; [["Male", false], ["Female", true]] %&gt;
    &lt;%= f.input :birthday, :start_year =&gt; 1900, :end_year =&gt; Time.now.year %&gt;
  &lt;% end -%&gt;
  &lt;% f.buttons do -%&gt;
   &lt;%= f.commit_button :label =&gt; "Update profile" %&gt;
  &lt;% end -%&gt;
&lt;% end %&gt;</pre>
<p>Special thanks to <a href="http://workingwithrails.com/person/6491-ryan-bates">Ryan Bates</a> who covered the gender case in <a href="http://railscasts.com/">Railscasts</a> <a href="http://railscasts.com/episodes/184-formtastic-part-1">episode 184</a> and <a href="http://asciicasts.com/about">Eifion Bedford</a> of <a href="http://asciicasts.com/">ASCIIcasts</a> for making it <a href="http://asciicasts.com/episodes/184-formtastic-part-1">easy to find</a>. It surely would have take me some time to figure it out.</p>
<p>Can you please <a href="http://sano.pupeno.com/profile/edit">update your profile on Sano</a>?</p>
<p>There you go 553 words!</p>
<br />Posted in Technical Tagged: building Sano, Rails, rest, Ruby, Ruby on Rails, Sano <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pupeno.wordpress.com/1392/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pupeno.wordpress.com/1392/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pupeno.wordpress.com/1392/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pupeno.wordpress.com/1392/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pupeno.wordpress.com/1392/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pupeno.wordpress.com/1392/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pupeno.wordpress.com/1392/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pupeno.wordpress.com/1392/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pupeno.wordpress.com/1392/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pupeno.wordpress.com/1392/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pupeno.wordpress.com/1392/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pupeno.wordpress.com/1392/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pupeno.wordpress.com/1392/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pupeno.wordpress.com/1392/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pupeno.com&amp;blog=8470507&amp;post=1392&amp;subd=pupeno&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pupeno.com/2009/11/22/my-profile-page-a-restful-single-resource-using-formtastic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/931970b8dc51b72e05e3a12b88612d61?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">Pablo</media:title>
		</media:content>

		<media:content url="http://pupeno.files.wordpress.com/2009/11/sano-0186.png" medium="image">
			<media:title type="html">sano-018</media:title>
		</media:content>
	</item>
		<item>
		<title>I love to code</title>
		<link>http://pupeno.com/2009/11/22/i-love-to-code/</link>
		<comments>http://pupeno.com/2009/11/22/i-love-to-code/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 03:51:19 +0000</pubDate>
		<dc:creator>Pablo</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[Bulding Sano]]></category>
		<category><![CDATA[Formtastic]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Sano]]></category>

		<guid isPermaLink="false">http://pupeno.com/?p=1374</guid>
		<description><![CDATA[I said I was done for the day more than 6 hours ago, but I love to code, I couldn&#8217;t stop. I wanted to implement a small feature: make the creation of new weights simpler for the common case and I did it: Note: That change is not yet deployed. I don&#8217;t play with servers [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pupeno.com&amp;blog=8470507&amp;post=1374&amp;subd=pupeno&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I said I was done for the day more than 6 hours ago, but I love to code, I couldn&#8217;t stop. I wanted to implement a small feature: make the creation of new weights simpler for the common case and I did it:</p>
<p><img class="alignnone size-full wp-image-1376" src="http://pupeno.files.wordpress.com/2009/11/sano-0178.png?w=538" alt="sano-017"   /></p>
<p>Note: That change is not yet deployed. I don&#8217;t play with servers while I&#8217;m half-asleep.</p>
<p>This took awfully long. The problem was that in the process I&#8217;ve found a bug in Formtastic, which made me realize I was running version 0.2.4 when the latest version was 0.9.2. That is because I was using justinfrench-formtastic:</p>
<pre>config.gem 'formtastic', :lib =&gt; 'justinfrench-formtastic'</pre>
<p>when I should have been using formtastic from gemcutter:</p>
<pre>config.gem 'formtastic'</pre>
<p>When I moved to 0.9.2 I&#8217;ve found two bugs on it, one was temporary solved and then reverted (and <a href="http://github.com/pupeno/formtastic/commit/d85fedb1b3fdff3d31ab8de8e22eaaba45676d1f">I fixed it by reverting the revertion</a>) and the other is still there but I&#8217;m not 100% confident <a href="http://github.com/pupeno/formtastic/commit/c78e927c9e7e104de9b9b2016d1dc277a900b0ae">my solution</a> is the appropriate one. At any rate <a href="http://github.com/pupeno/formtastic">I forked Formtastic in GitHub</a>, fixed the bugs and made a merge request.</p>
<p>Conclusion: Git is great, GitHub is great, Formtastic is great, open source is great, Rails is great and yes, I am great ;)</p>
<br />Posted in Technical Tagged: Bulding Sano, Formtastic, Rails, Ruby, Ruby on Rails, Sano <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pupeno.wordpress.com/1374/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pupeno.wordpress.com/1374/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pupeno.wordpress.com/1374/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pupeno.wordpress.com/1374/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pupeno.wordpress.com/1374/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pupeno.wordpress.com/1374/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pupeno.wordpress.com/1374/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pupeno.wordpress.com/1374/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pupeno.wordpress.com/1374/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pupeno.wordpress.com/1374/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pupeno.wordpress.com/1374/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pupeno.wordpress.com/1374/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pupeno.wordpress.com/1374/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pupeno.wordpress.com/1374/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pupeno.com&amp;blog=8470507&amp;post=1374&amp;subd=pupeno&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pupeno.com/2009/11/22/i-love-to-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/931970b8dc51b72e05e3a12b88612d61?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">Pablo</media:title>
		</media:content>

		<media:content url="http://pupeno.files.wordpress.com/2009/11/sano-0178.png" medium="image">
			<media:title type="html">sano-017</media:title>
		</media:content>
	</item>
		<item>
		<title>Sano is open for business</title>
		<link>http://pupeno.com/2009/11/21/sano-is-open-for-business/</link>
		<comments>http://pupeno.com/2009/11/21/sano-is-open-for-business/#comments</comments>
		<pubDate>Sat, 21 Nov 2009 21:04:58 +0000</pubDate>
		<dc:creator>Pablo</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[building Sano]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Sano]]></category>

		<guid isPermaLink="false">http://pupeno.com/?p=1371</guid>
		<description><![CDATA[I really wish I was able to get farther in one day, but I think it&#8217;s good enough that I went from idea to deployed app. On retrospective I wasted too much time figuring out formtastic. I don&#8217;t regret doing it because it was in my TODO list and in the long run it should [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pupeno.com&amp;blog=8470507&amp;post=1371&amp;subd=pupeno&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I really wish I was able to get farther in one day, but I think it&#8217;s good enough that I went from idea to deployed app. On retrospective I wasted too much time figuring out formtastic. I don&#8217;t regret doing it because it was in my TODO list and in the long run it should make me more productive, but in the short run maybe I should have used the good old forms.</p>
<p>The other two big waste of times was CSS and tables and an issue with the Ruby OpenID gem. Both problems I encountered before and both times I gave up trying to solve them and moved on. I should have moved on again this time; but instead I figured them out.</p>
<p>The application is at <a href="http://sano.pupeno.com">http://sano.pupeno.com</a>. Please don&#8217;t break it ;) Remember to log in and if you add data I&#8217;ll be grateful as it&#8217;ll make my migrations more realistic:</p>
<p><img class="alignnone size-full wp-image-1372" src="http://pupeno.files.wordpress.com/2009/11/sano-0168.png?w=538" alt="sano-016"   /></p>
<p>I&#8217;m done for today.</p>
<br />Posted in Technical Tagged: building Sano, Rails, Ruby, Ruby on Rails, Sano <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pupeno.wordpress.com/1371/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pupeno.wordpress.com/1371/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pupeno.wordpress.com/1371/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pupeno.wordpress.com/1371/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pupeno.wordpress.com/1371/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pupeno.wordpress.com/1371/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pupeno.wordpress.com/1371/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pupeno.wordpress.com/1371/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pupeno.wordpress.com/1371/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pupeno.wordpress.com/1371/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pupeno.wordpress.com/1371/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pupeno.wordpress.com/1371/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pupeno.wordpress.com/1371/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pupeno.wordpress.com/1371/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pupeno.com&amp;blog=8470507&amp;post=1371&amp;subd=pupeno&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pupeno.com/2009/11/21/sano-is-open-for-business/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/931970b8dc51b72e05e3a12b88612d61?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">Pablo</media:title>
		</media:content>

		<media:content url="http://pupeno.files.wordpress.com/2009/11/sano-0168.png" medium="image">
			<media:title type="html">sano-016</media:title>
		</media:content>
	</item>
		<item>
		<title>Super Exception Notifier</title>
		<link>http://pupeno.com/2009/11/21/super-exception-notifier/</link>
		<comments>http://pupeno.com/2009/11/21/super-exception-notifier/#comments</comments>
		<pubDate>Sat, 21 Nov 2009 20:11:53 +0000</pubDate>
		<dc:creator>Pablo</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[building Sano]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Sano]]></category>

		<guid isPermaLink="false">http://pupeno.com/?p=1363</guid>
		<description><![CDATA[I like knowing when something goes wrong with my web apps, so I&#8217;m using Super Exception Notifier to get by email a report should any exception be raised in the app. If you go to Super Exception Notifier&#8217;s site you&#8217;ll see some instructions on how to add it to your project. This is how I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pupeno.com&amp;blog=8470507&amp;post=1363&amp;subd=pupeno&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I like knowing when something goes wrong with my web apps, so I&#8217;m using <a href="http://github.com/pboling/exception_notification">Super Exception Notifier</a> to get by email a report should any exception be raised in the app. If you go to Super Exception Notifier&#8217;s site you&#8217;ll see some instructions on how to add it to your project. This is how I do it.</p>
<p>Add the gem requirement in environment.rb:</p>
<pre>
config.gem 'super_exception_notifier', :version =&gt; '~&gt; 2.0.0', :lib =&gt; 'exception_notifier'
</pre>
<p>Then be sure to have gemcutter in your gem sources:</p>
<pre>gem sources
*** CURRENT SOURCES ***

http://gemcutter.org

http://gems.rubyforge.org/

http://gems.github.com
</pre>
<p>If you don&#8217;t have it, you can add it this way:</p>
<pre>gem install gemcutter</pre>
<pre>gem tumble</pre>
<p>To install the gem, in your Rails project run:</p>
<pre>sudo rake gems:install</pre>
<p>Create a file in config/initializers, I&#8217;ve called it exception_notifier.rb and inside I&#8217;ve set up the only really needed value for the notifications, the email address:</p>
<pre>
# Notification configuration
ExceptionNotifier.configure_exception_notifier do |config|
  config[:exception_recipients] = %w(pupeno@pupeno.com)
end
</pre>
<p>The last task is to make your application controller noisy by adding one line to it (the second one of course):</p>
<pre>
class ApplicationController &lt; ActionController::Base
  include ExceptionNotifiable
  #...
end
</pre>
<p>You also need to be sure that you have ActionMailer properly configured, otherwise no mail is going to get through.</p>
<br />Posted in Technical Tagged: building Sano, Rails, Ruby, Ruby on Rails, Sano <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pupeno.wordpress.com/1363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pupeno.wordpress.com/1363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pupeno.wordpress.com/1363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pupeno.wordpress.com/1363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pupeno.wordpress.com/1363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pupeno.wordpress.com/1363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pupeno.wordpress.com/1363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pupeno.wordpress.com/1363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pupeno.wordpress.com/1363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pupeno.wordpress.com/1363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pupeno.wordpress.com/1363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pupeno.wordpress.com/1363/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pupeno.wordpress.com/1363/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pupeno.wordpress.com/1363/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pupeno.com&amp;blog=8470507&amp;post=1363&amp;subd=pupeno&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pupeno.com/2009/11/21/super-exception-notifier/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/931970b8dc51b72e05e3a12b88612d61?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">Pablo</media:title>
		</media:content>
	</item>
		<item>
		<title>Merging users</title>
		<link>http://pupeno.com/2009/11/21/merging-users/</link>
		<comments>http://pupeno.com/2009/11/21/merging-users/#comments</comments>
		<pubDate>Sat, 21 Nov 2009 19:55:13 +0000</pubDate>
		<dc:creator>Pablo</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[building Sano]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Sano]]></category>

		<guid isPermaLink="false">http://pupeno.com/?p=1357</guid>
		<description><![CDATA[Remember that I said that when you log in, your ghost user has to be merged with the real user? Well, this is the code for doing it: class User &#60; ActiveRecord::Base #... def merge(user_id) if user_id != nil user = User.find(user_id) user.weights.each do &#124;weight&#124; weight.user = self weight.save end user.destroy end end end The [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pupeno.com&amp;blog=8470507&amp;post=1357&amp;subd=pupeno&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="/blog/getting-the-current-user/">Remember that I said that when you log in, your ghost user has to be merged with the real user?</a> Well, this is the code for doing it:</p>
<pre>
class User &lt; ActiveRecord::Base
  #...

  def merge(user_id)
    if user_id != nil
      user = User.find(user_id)

      user.weights.each do |weight|
        weight.user = self
        weight.save
      end

      user.destroy
    end
  end
end
</pre>
<p>The problem with this is that it&#8217;s very error prone. You have to make sure that every model that is related to the user model gets properly handled.</p>
<br />Posted in Technical Tagged: building Sano, Rails, Ruby, Ruby on Rails, Sano <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pupeno.wordpress.com/1357/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pupeno.wordpress.com/1357/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pupeno.wordpress.com/1357/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pupeno.wordpress.com/1357/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pupeno.wordpress.com/1357/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pupeno.wordpress.com/1357/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pupeno.wordpress.com/1357/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pupeno.wordpress.com/1357/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pupeno.wordpress.com/1357/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pupeno.wordpress.com/1357/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pupeno.wordpress.com/1357/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pupeno.wordpress.com/1357/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pupeno.wordpress.com/1357/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pupeno.wordpress.com/1357/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pupeno.com&amp;blog=8470507&amp;post=1357&amp;subd=pupeno&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pupeno.com/2009/11/21/merging-users/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/931970b8dc51b72e05e3a12b88612d61?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">Pablo</media:title>
		</media:content>
	</item>
		<item>
		<title>Simplifying the weight CRUD</title>
		<link>http://pupeno.com/2009/11/21/simplifying-the-weight-crud/</link>
		<comments>http://pupeno.com/2009/11/21/simplifying-the-weight-crud/#comments</comments>
		<pubDate>Sat, 21 Nov 2009 19:03:16 +0000</pubDate>
		<dc:creator>Pablo</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[building Sano]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Sano]]></category>

		<guid isPermaLink="false">http://pupeno.com/?p=1345</guid>
		<description><![CDATA[After a rather long fight with formtastic I have a better CRUD for weight: But now that I think about it, there shouldn&#8217;t be a measured at in this view. That should be in an advanced new-form. Posted in Technical Tagged: building Sano, Rails, Ruby, Ruby on Rails, Sano<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pupeno.com&amp;blog=8470507&amp;post=1345&amp;subd=pupeno&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>After a rather long fight with formtastic I have a better CRUD for weight:</p>
<p><img class="alignnone size-full wp-image-1346" src="http://pupeno.files.wordpress.com/2009/11/sone-0127.png?w=538" alt="sone-012"   /></p>
<p>But now that I think about it, there shouldn&#8217;t be a measured at in this view. That should be in an advanced new-form.</p>
<br />Posted in Technical Tagged: building Sano, Rails, Ruby, Ruby on Rails, Sano <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pupeno.wordpress.com/1345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pupeno.wordpress.com/1345/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pupeno.wordpress.com/1345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pupeno.wordpress.com/1345/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pupeno.wordpress.com/1345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pupeno.wordpress.com/1345/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pupeno.wordpress.com/1345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pupeno.wordpress.com/1345/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pupeno.wordpress.com/1345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pupeno.wordpress.com/1345/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pupeno.wordpress.com/1345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pupeno.wordpress.com/1345/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pupeno.wordpress.com/1345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pupeno.wordpress.com/1345/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pupeno.com&amp;blog=8470507&amp;post=1345&amp;subd=pupeno&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pupeno.com/2009/11/21/simplifying-the-weight-crud/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/931970b8dc51b72e05e3a12b88612d61?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">Pablo</media:title>
		</media:content>

		<media:content url="http://pupeno.files.wordpress.com/2009/11/sone-0127.png" medium="image">
			<media:title type="html">sone-012</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating the weight model and scaffolding</title>
		<link>http://pupeno.com/2009/11/21/creating-the-weight-model-and-scaffolding/</link>
		<comments>http://pupeno.com/2009/11/21/creating-the-weight-model-and-scaffolding/#comments</comments>
		<pubDate>Sat, 21 Nov 2009 14:05:08 +0000</pubDate>
		<dc:creator>Pablo</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[building Sano]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Sano]]></category>
		<category><![CDATA[scaffolding]]></category>

		<guid isPermaLink="false">http://pupeno.com/?p=1308</guid>
		<description><![CDATA[With one command line I&#8217;ve created the weight model and the scaffolding, a fully functional CRUD little app without my Rails app. I know all Rails developer are rolling eyes now; but I still think this is awesome. It gets you up and running so fast: ./script/generate scaffold weight user_id:integer weight:float timestamp:datetime exists app/models/ exists [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pupeno.com&amp;blog=8470507&amp;post=1308&amp;subd=pupeno&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>With one command line I&#8217;ve created the weight model and the scaffolding, a fully functional CRUD little app without my Rails app. I know all Rails developer are rolling eyes now; but I still think this is awesome. It gets you up and running so fast:</p>
<pre> ./script/generate scaffold weight user_id:integer weight:float timestamp:datetime
      exists  app/models/
      exists  app/controllers/
      exists  app/helpers/
      create  app/views/weights
      create  app/views/layouts/
      create  test/functional/
      exists  test/unit/
      create  test/unit/helpers/
      create  public/stylesheets/
      create  app/views/weights/index.html.erb
      create  app/views/weights/show.html.erb
      create  app/views/weights/new.html.erb
      create  app/views/weights/edit.html.erb
      create  app/views/layouts/weights.html.erb
      create  public/stylesheets/scaffold.css
      create  app/controllers/weights_controller.rb
      create  test/functional/weights_controller_test.rb
      create  app/helpers/weights_helper.rb
      create  test/unit/helpers/weights_helper_test.rb
       route  map.resources :weights
  dependency  model
      exists    app/models/
      exists    test/unit/
      exists    test/fixtures/
      create    app/models/weight.rb
      create    test/unit/weight_test.rb
      create    test/fixtures/weights.yml
      exists    db/migrate
      create    db/migrate/20091121135320_create_weights.rb</pre>
<p>And this is what I&#8217;ve got:</p>
<p><img class="alignnone size-full wp-image-1309" src="http://pupeno.files.wordpress.com/2009/11/sano-0037.png?w=538" alt="sano-003"   /></p>
<p><img class="alignnone size-full" src="http://pupeno.files.wordpress.com/2009/11/sano-0049.png?w=538" alt="sano-004"   /></p>
<p><img class="alignnone size-full" src="http://pupeno.files.wordpress.com/2009/11/sano-0059.png?w=538" alt="sano-005"   /></p>
<p><img class="alignnone size-full" src="http://pupeno.files.wordpress.com/2009/11/sano-0069.png?w=538" alt="sano-006"   /></p>
<p><img class="alignnone size-full" src="http://pupeno.files.wordpress.com/2009/11/sano-0079.png?w=538" alt="sano-007"   /></p>
<p><img class="alignnone size-full" src="http://pupeno.files.wordpress.com/2009/11/sano-0089.png?w=538" alt="sano-008"   /></p>
<br />Posted in Technical Tagged: building Sano, Rails, Ruby on Rails, Sano, scaffolding <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pupeno.wordpress.com/1308/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pupeno.wordpress.com/1308/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pupeno.wordpress.com/1308/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pupeno.wordpress.com/1308/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pupeno.wordpress.com/1308/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pupeno.wordpress.com/1308/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pupeno.wordpress.com/1308/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pupeno.wordpress.com/1308/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pupeno.wordpress.com/1308/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pupeno.wordpress.com/1308/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pupeno.wordpress.com/1308/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pupeno.wordpress.com/1308/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pupeno.wordpress.com/1308/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pupeno.wordpress.com/1308/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pupeno.com&amp;blog=8470507&amp;post=1308&amp;subd=pupeno&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pupeno.com/2009/11/21/creating-the-weight-model-and-scaffolding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/931970b8dc51b72e05e3a12b88612d61?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">Pablo</media:title>
		</media:content>

		<media:content url="http://pupeno.files.wordpress.com/2009/11/sano-0037.png" medium="image">
			<media:title type="html">sano-003</media:title>
		</media:content>

		<media:content url="http://pupeno.files.wordpress.com/2009/11/sano-0049.png" medium="image">
			<media:title type="html">sano-004</media:title>
		</media:content>

		<media:content url="http://pupeno.files.wordpress.com/2009/11/sano-0059.png" medium="image">
			<media:title type="html">sano-005</media:title>
		</media:content>

		<media:content url="http://pupeno.files.wordpress.com/2009/11/sano-0069.png" medium="image">
			<media:title type="html">sano-006</media:title>
		</media:content>

		<media:content url="http://pupeno.files.wordpress.com/2009/11/sano-0079.png" medium="image">
			<media:title type="html">sano-007</media:title>
		</media:content>

		<media:content url="http://pupeno.files.wordpress.com/2009/11/sano-0089.png" medium="image">
			<media:title type="html">sano-008</media:title>
		</media:content>
	</item>
	</channel>
</rss>
