<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:posterous="http://posterous.com/help/rss/1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
  <channel>
    <title>OpenHouseConcept</title>
    <link>http://blog.openhouseconcept.com</link>
    <description>Specializing in web application development.</description>
    <generator>posterous.com</generator>
    <link xmlns="http://www.w3.org/2005/Atom" href="http://posterous.com/api/sup_update#bc4c85adc" type="application/json" rel="http://api.friendfeed.com/2008/03#sup" />
    
    
    <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/openhouseconcept" /><feedburner:info uri="openhouseconcept" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://posterous.superfeedr.com/" /><item>
      <pubDate>Tue, 17 Nov 2009 11:11:50 -0800</pubDate>
      <title>Firefox extension toolbar sprite</title>
      <link>http://feedproxy.google.com/~r/openhouseconcept/~3/v_NGUaF-BE0/firefox-extension-toolbar-sprite</link>
      <guid isPermaLink="false">http://blog.openhouseconcept.com/firefox-extension-toolbar-sprite</guid>
      <description>&lt;p&gt;
	&lt;div class='p_embed p_image_embed'&gt;
&lt;img alt="Generic" height="69" src="http://posterous.com/getfile/files.posterous.com/openhouse/u0cj1xCxxdvw1f2rtcW8pk11fkrZuwkwmsya6SaNvpwwT4JLEgXpsbOZn9Gr/generic.png" width="36" /&gt;
&lt;/div&gt;
&lt;p&gt;Here is a generic image of the sprite needed for the toolbar in a firefox extension. It has three states&lt;br /&gt;as a part of the sprite. &lt;p /&gt;Top: generic state of button &lt;br /&gt;Middle: is the :hover state of the button &lt;br /&gt;Bottom: is the :active state of the button &lt;p /&gt; Just add your icon on top of these three states in the exact same place (so it does not jump on rollover, etc) and export as png.&lt;br /&gt;This image works with the standard css provided by firefox, so no need for adjustment.&lt;br /&gt;&lt;/p&gt;
	
&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blog.openhouseconcept.com/firefox-extension-toolbar-sprite"&gt;Permalink&lt;/a&gt; 

	| &lt;a href="http://blog.openhouseconcept.com/firefox-extension-toolbar-sprite#comment"&gt;Leave a comment&amp;nbsp;&amp;nbsp;&amp;raquo;&lt;/a&gt;

&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/openhouseconcept/~4/v_NGUaF-BE0" height="1" width="1"/&gt;</description>
      <posterous:author>
        <posterous:userImage>http://posterous.com/images/profile/missing-user-75.png</posterous:userImage>
        <posterous:profileUrl>http://posterous.com/users/4bmXmLCf6mRP</posterous:profileUrl>
        <posterous:firstName>OpenHouse</posterous:firstName>
        <posterous:lastName>Concept</posterous:lastName>
        <posterous:nickName>OpenHouse</posterous:nickName>
        <posterous:displayName>OpenHouse Concept</posterous:displayName>
      </posterous:author>
      <media:content type="image/png" height="69" width="36" url="http://getfile1.posterous.com/getfile/files.posterous.com/openhouse/u0cj1xCxxdvw1f2rtcW8pk11fkrZuwkwmsya6SaNvpwwT4JLEgXpsbOZn9Gr/generic.png">
        <media:thumbnail height="69" width="36" url="http://getfile1.posterous.com/getfile/files.posterous.com/openhouse/u0cj1xCxxdvw1f2rtcW8pk11fkrZuwkwmsya6SaNvpwwT4JLEgXpsbOZn9Gr/generic.png" />
      </media:content>
    <feedburner:origLink>http://blog.openhouseconcept.com/firefox-extension-toolbar-sprite</feedburner:origLink></item>
    <item>
      <pubDate>Thu, 22 Oct 2009 14:19:00 -0700</pubDate>
      <title>sIFR transparent wmode in IE6</title>
      <link>http://feedproxy.google.com/~r/openhouseconcept/~3/C8pulz3eO9U/sifr-transparent-wmode-in-ie6</link>
      <guid isPermaLink="false">http://blog.openhouseconcept.com/sifr-transparent-wmode-in-ie6</guid>
      <description>&lt;p&gt;
	&lt;p&gt;If you are using sIFR and have the requirement to have the generated flash file be transparent you will end up using the "wmode: 'transparent'" option. We ran into a tricky js bug in IE 6 that only happens when the browser window is resized. The only feedback you will receive is the dreaded IE 6 error box.&lt;/p&gt;
&lt;p&gt;&lt;div class='p_embed p_image_embed'&gt;
&lt;img alt="Ie6_js_error" height="290" src="http://posterous.com/getfile/files.posterous.com/openhouse/jInrUNMHiYr34f70c4HL5cvgMTitWNiboW3TH9AB80vWqpwamt0diIjXBCmJ/ie6_js_error.png" width="452" /&gt;
&lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;The solution to this heinous bug is very simple, but not easily found. &lt;p /&gt; In the sIFR config file, add the following line just above sIFR.activate(..); &lt;p /&gt; sIFR.repaintOnResize = false; &lt;p /&gt; According to the sIFR documentation repaintOnResize "Determines whether sIFR updates the Flash movie when the window is resized. Necessary for page zoom as well." &lt;p /&gt; Why this flag is defaulted to true and why sIFR needs to update the flash movie on browser resize is still a mystery . I have not noticed a change in behavior by disabling this flag (other than making the bug disappear). &lt;p /&gt; So in conclusion if you need to support IE 6 and sIFR transparency then this should save you a headache or two.&lt;/p&gt;
	
&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blog.openhouseconcept.com/sifr-transparent-wmode-in-ie6"&gt;Permalink&lt;/a&gt; 

	| &lt;a href="http://blog.openhouseconcept.com/sifr-transparent-wmode-in-ie6#comment"&gt;Leave a comment&amp;nbsp;&amp;nbsp;&amp;raquo;&lt;/a&gt;

&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/openhouseconcept/~4/C8pulz3eO9U" height="1" width="1"/&gt;</description>
      <posterous:author>
        <posterous:userImage>http://posterous.com/images/profile/missing-user-75.png</posterous:userImage>
        <posterous:profileUrl>http://posterous.com/users/4bmXmLCf6mRP</posterous:profileUrl>
        <posterous:firstName>OpenHouse</posterous:firstName>
        <posterous:lastName>Concept</posterous:lastName>
        <posterous:nickName>OpenHouse</posterous:nickName>
        <posterous:displayName>OpenHouse Concept</posterous:displayName>
      </posterous:author>
      <media:content type="image/png" height="290" width="452" url="http://getfile5.posterous.com/getfile/files.posterous.com/openhouse/jInrUNMHiYr34f70c4HL5cvgMTitWNiboW3TH9AB80vWqpwamt0diIjXBCmJ/ie6_js_error.png">
        <media:thumbnail height="290" width="452" url="http://getfile5.posterous.com/getfile/files.posterous.com/openhouse/jInrUNMHiYr34f70c4HL5cvgMTitWNiboW3TH9AB80vWqpwamt0diIjXBCmJ/ie6_js_error.png" />
      </media:content>
    <feedburner:origLink>http://blog.openhouseconcept.com/sifr-transparent-wmode-in-ie6</feedburner:origLink></item>
    <item>
      <pubDate>Fri, 09 Oct 2009 11:37:00 -0700</pubDate>
      <title>Revealing intent in your controllers with named_scope</title>
      <link>http://feedproxy.google.com/~r/openhouseconcept/~3/6Ms9u2jQXPs/revealing-intent-in-your-controllers-with-nam</link>
      <guid isPermaLink="false">http://blog.openhouseconcept.com/revealing-intent-in-your-controllers-with-nam</guid>
      <description>&lt;p&gt;
	&lt;p&gt;I have been thinking lately about how many Rails controller actions I run into that are hard to read and do not reveal the actual intent of the person that wrote the software. This can be extremely frustrating for a developer working with code that they did not originally write.&lt;p /&gt;Consider the following example:&lt;p /&gt;We have an Article model that has an Article Type and belongs to a User. Any time a User creates/updates an Article, a Boolean "approved" attribute is set to false.&lt;p /&gt;The Article migration file might look something like this:&lt;/p&gt;
&lt;blockquote class="posterous_medium_quote"&gt;class CreateArticles &amp;lt; ActiveRecord::Migration&lt;br /&gt;&amp;nbsp; def self.up&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; create_table :articles do |t|&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t.string&amp;nbsp; :title, :limit =&amp;gt; 155, :null =&amp;gt; false&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t.text :content, :null =&amp;gt; false&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t.integer :user_id, :null =&amp;gt; false&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t.integer :article_type_id, :null =&amp;gt; true&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t.boolean :approved, :default =&amp;gt; false, :null =&amp;gt; false&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t.timestamps&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end&lt;br /&gt;&amp;nbsp; end &lt;p /&gt;&amp;nbsp; def self.down&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; drop_table :articles&lt;br /&gt;&amp;nbsp; end&lt;br /&gt;end&lt;/blockquote&gt;
&lt;p&gt;&lt;p /&gt;So a simple requirement in this case might be for the site Administrator to be able to "approve" articles. The business refers to unapproved articles as "pending". To do this, we would need to find all of the Articles that have an "approved" value of false. We would also need to order the results by date to return the most recent article changes first.&lt;p /&gt;Here is an example of how one could accomplish this query in the controller:&lt;/p&gt;
&lt;blockquote class="posterous_medium_quote"&gt;class PendingArticlesController &amp;lt;&amp;nbsp; ApplicationController&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; def index&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @articles = Article.find(:all, :include =&amp;gt; [:user, :article_type], :conditions =&amp;gt; ["approved = ?", false], :order =&amp;gt; 'updated_at DESC')&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end&lt;br /&gt;end&lt;/blockquote&gt;
&lt;p&gt;&lt;p /&gt;There is nothing really wrong with the above find but there are a few things we can do to improve the code by revealing more intent and using the Projects Ubiquitous Language.&lt;p /&gt;Enter named_scope:&lt;br /&gt;From the Rails documentation, named_scope "Adds a class method for retrieving and querying objects. A scope represents a narrowing of a database query"&lt;p /&gt;By using named_scope, we can refactor the controller code as follows:&lt;p /&gt;Introduce named_scope into the Article model&lt;/p&gt;
&lt;blockquote class="posterous_medium_quote"&gt;class Article &amp;lt; ActiveRecord::Base&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; named_scope :pending, :include =&amp;gt; [:user, :article_type], :conditions =&amp;gt; ["approved = ?", false], :order =&amp;gt; 'updated_at DESC'&lt;br /&gt;end&lt;/blockquote&gt;
&lt;p&gt;&lt;br /&gt;We can now update our controller code to use our new named_scope&lt;/p&gt;
&lt;blockquote class="posterous_medium_quote"&gt;class PendingArticlesController &amp;lt;&amp;nbsp; ApplicationController&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; def index&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @pending_articles = Article.pending&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end&lt;/blockquote&gt;
&lt;p&gt;&lt;br /&gt;end&lt;p /&gt;This is much better! Now we have a very simple controller action which is easy to read and understand at a glance. We have also moved the find logic into the Article, which is where it belongs.&lt;p /&gt;While this is a very simple example, consider a controller action with many lines and very large find statements. These can become very difficult to understand and hard to maintain.&lt;/p&gt;
&lt;div&gt;Hopefully this small tip helps.
&lt;p /&gt;
&lt;div&gt;
&lt;p&gt;Reference:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://martinfowler.com/bliki/UbiquitousLanguage.html" title="Ubiquitous Language Definition"&gt;Ubiquitous Language&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.informit.com/articles/article.aspx?p=357688" title="Programming by Intention"&gt;Programming by Intention&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://api.rubyonrails.org/classes/ActiveRecord/NamedScope/ClassMethods.html#M002177" title="named_scope documentation"&gt;named_scope documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
	
&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blog.openhouseconcept.com/revealing-intent-in-your-controllers-with-nam"&gt;Permalink&lt;/a&gt; 

	| &lt;a href="http://blog.openhouseconcept.com/revealing-intent-in-your-controllers-with-nam#comment"&gt;Leave a comment&amp;nbsp;&amp;nbsp;&amp;raquo;&lt;/a&gt;

&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/openhouseconcept/~4/6Ms9u2jQXPs" height="1" width="1"/&gt;</description>
      <posterous:author>
        <posterous:userImage>http://posterous.com/images/profile/missing-user-75.png</posterous:userImage>
        <posterous:profileUrl>http://posterous.com/users/4bmXmLCf6mRP</posterous:profileUrl>
        <posterous:firstName>OpenHouse</posterous:firstName>
        <posterous:lastName>Concept</posterous:lastName>
        <posterous:nickName>OpenHouse</posterous:nickName>
        <posterous:displayName>OpenHouse Concept</posterous:displayName>
      </posterous:author>
    <feedburner:origLink>http://blog.openhouseconcept.com/revealing-intent-in-your-controllers-with-nam</feedburner:origLink></item>
    <item>
      <pubDate>Wed, 30 Sep 2009 12:36:56 -0700</pubDate>
      <title>New Website</title>
      <link>http://feedproxy.google.com/~r/openhouseconcept/~3/hWs-YHEU20I/new-website-71</link>
      <guid isPermaLink="false">http://blog.openhouseconcept.com/new-website-71</guid>
      <description>&lt;p&gt;
	We're thrilled to launch our new website. Please take a look around and let us know what you think! &lt;p /&gt; Any and all feedback is welcome.
	
&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blog.openhouseconcept.com/new-website-71"&gt;Permalink&lt;/a&gt; 

	| &lt;a href="http://blog.openhouseconcept.com/new-website-71#comment"&gt;Leave a comment&amp;nbsp;&amp;nbsp;&amp;raquo;&lt;/a&gt;

&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/openhouseconcept/~4/hWs-YHEU20I" height="1" width="1"/&gt;</description>
      <posterous:author>
        <posterous:userImage>http://posterous.com/images/profile/missing-user-75.png</posterous:userImage>
        <posterous:profileUrl>http://posterous.com/users/4bmXmLCf6mRP</posterous:profileUrl>
        <posterous:firstName>OpenHouse</posterous:firstName>
        <posterous:lastName>Concept</posterous:lastName>
        <posterous:nickName>OpenHouse</posterous:nickName>
        <posterous:displayName>OpenHouse Concept</posterous:displayName>
      </posterous:author>
    <feedburner:origLink>http://blog.openhouseconcept.com/new-website-71</feedburner:origLink></item>
  </channel>
</rss>

