<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>The Vose Way: Category Programming</title>
    <link>http://www.chuckvose.com/articles/category/programming</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>A Blog about Butter, Cheese, and Ruby on Rails</description>
    <item>
      <title>Pagination, Sets, Checkboxes</title>
      <description>&lt;p&gt;When I was at RailsConf2008 I learned a lot about life and Rails but there were some nagging problems that lingered after me for a long time.&lt;/p&gt;


	&lt;p&gt;At one point in the talks there was a discussion of how to make listing pages have checkboxes and how to handle this data. The problem is complicated by pagination and filtering so it&amp;#8217;s actually a really good problem to talk about.&lt;/p&gt;


	&lt;p&gt;The proposed solution was to send back a structure that looked something like this:&lt;/p&gt;


&lt;pre&gt;
[{:id =&amp;gt; 1, :activated =&amp;gt; "+", :contact =&amp;gt; "-"}, ...]
&lt;/pre&gt;

	&lt;p&gt;At this point I was probably playing pogs in the audience with Ryan Schenk so the details are lost to time but the concept remains.&lt;/p&gt;


	&lt;p&gt;It seems needlessly complex though. A very interesting idea, no doubt about it, and it certainly has its merit but it seems very complex to me when we&amp;#8217;re talking about booleans. Also, I feel like it&amp;#8217;s worth mentioning that this method is much faster than the below method but somehow that doesn&amp;#8217;t turn me off that badly.&lt;/p&gt;


	&lt;p&gt;Instead of the above I took the already well accepted practice of using the check_box_tag in the view with the addition of a hidden field which would tell me which objects to care about:&lt;/p&gt;


&lt;pre&gt;
&amp;lt;% @users.each do |user| %&amp;gt;
  &amp;lt;%= hidden_field_tag('seen[]', user.id) -%&amp;gt;
  &amp;lt;%= check_box_tag 'activated[]', user.id -%&amp;gt;
&amp;lt;% end %&amp;gt;
&lt;/pre&gt;

	&lt;p&gt;In the controller it&amp;#8217;s as easy as loading up params[:seen] and loading each object:&lt;/p&gt;


&lt;pre&gt;
def index
  if request.post?
    activated_ids = params[:activated].collect {|id| id.to_i} if params[:activated]
    seen_ids = params[:seen].collect {|id| id.to_i} if params[:seen]

    if activated_ids
      seen_ids.each do |id|
        r = User.find_by_id(id)
        r.activated = activated_ids.include?(id)
        r.save
      end
    end
  end
end
&lt;/pre&gt;

	&lt;p&gt;So what I don&amp;#8217;t get is whether this is wrong on some moral stance or if I really didn&amp;#8217;t understand what the presenter was getting at. Yes, he loads and saves fewer objects, which could be important. But he also introduced what seems to me to be a lot of complexity into a fairly simple process.&lt;/p&gt;


	&lt;p&gt;At any rate, this code is here in case someone needs to find it until I find what the presenter was proposing. I seem to recall being impressed at the time so there must be something I&amp;#8217;ve forgotten.&lt;/p&gt;</description>
      <pubDate>Mon, 25 Aug 2008 15:29:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:1f1a423f-d1ae-4d35-a981-25ca8ca91372</guid>
      <author>vosechu@create-on.com (Chuck Vose)</author>
      <link>http://www.chuckvose.com/articles/2008/08/25/pagination-sets-checkboxes</link>
      <category>Ruby</category>
      <category>Rails</category>
      <category>Programming</category>
      <category>check_box</category>
      <category>check_box_tag</category>
      <category>Rails</category>
      <category>Ruby</category>
      <category>view</category>
      <category>list</category>
      <category>index</category>
      <category>pagination</category>
      <category>filter</category>
      <category>check</category>
      <category>boxes</category>
      <category>multiple</category>
    </item>
    <item>
      <title>Mnesia to ruby bridge evaluation</title>
      <description>&lt;p&gt;Owing to the complexities of building a Rails adapter for Mnesia I&amp;#8217;ve been looking into using a Ruby to Erlang bridge and have looked at the various projects that seem to be available and want to share my comments on how each is stacking up so far.&lt;/p&gt;


	&lt;h2&gt;Rebar&lt;/h2&gt;


	&lt;p&gt;&lt;a href="http://rubyisawesome.com/2007/4/30/calling-erlang-from-ruby-teaser"&gt;Rebar&lt;/a&gt; was announced on 2007-04-20 and has since never surfaced to the public as far as his blog and Google are concerned. The code looked to be among the easiest to understand but is thankfully very similar to the Japanese RulangBridge below. The existence of the Japanese project could explain why Tom Werner never finished the project but that&amp;#8217;s merely a guess.&lt;/p&gt;


	&lt;h2&gt;Erlectricity&lt;/h2&gt;


	&lt;p&gt;&lt;a href="http://nullstyle.com/2007/05/08/erlectricity-hi-ruby-im-erlang/"&gt;Erlectricity&lt;/a&gt; by Scott Fleckenstein was the first project I really tried out and I am impressed by some aspects and disappointed by others. On one hand it was easy to obtain being hosted on &lt;a href="https://rubyforge.org/projects/erlectricity/"&gt;RubyForge&lt;/a&gt; and &lt;a href="http://code.google.com/p/erlectricity/"&gt;Google Code&lt;/a&gt; and works well at using Ruby from Erlang. On the other hand it comes with no documentation or rdocs outside of two uncommented examples.&lt;/p&gt;


	&lt;p&gt;I could never figure out a way to get it to bridge Erlang commands from Ruby but there may be a way that I&amp;#8217;m missing; I have to admit I&amp;#8217;ve not asked Scott about whether this code can go both ways or not.&lt;/p&gt;


	&lt;p&gt;So if you need something that Ruby does well but Erlang doesn&amp;#8217;t then this may be your project. The second example uses the bridge to generate a gruff graph from Erlang which seems like it&amp;#8217;ll come in handy for a lot of people.&lt;/p&gt;


	&lt;p&gt;Outside of documentation I&amp;#8217;m concerned about whether the bridge can handle asynchronous requests from Erlang. From first glance it doesn&amp;#8217;t seem like there&amp;#8217;s any blocking and each Erlang thread calls the script directly instead of central blocking thread so I&amp;#8217;m guessing that there&amp;#8217;s no concurrency built in; something that we would have to work with if we were to use this bridge for a many-threaded project.&lt;/p&gt;


	&lt;h2&gt;RulangBridge&lt;/h2&gt;


	&lt;p&gt;&lt;a href="http://code.google.com/p/rulangbridge/"&gt;RulangBridge&lt;/a&gt; by Toshi Hirooka (?) is a Japanese project allowing Ruby to use Erlang functions. Google&amp;#8217;s translation allows us to read the usage instructions and browse the code which has allowed me to start using it in earnest to build the &lt;a href="http://www.chuckvose.com/articles/2007/12/22/mnesia-ruby-announcement"&gt;Ruby to Mnesia bridge&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;My first impressions are that the bridge is that it is a little immature despite the &amp;gt;1.0 release number. The example code is excellent (if in Japanese) but it isn&amp;#8217;t packaged in a gem or hosted on RubyForge and doesn&amp;#8217;t have a way to auto-start an Erlang server. Furthermore, using only the built in classes we have to make the choice of asynchronicity or complicated/multi-module code.&lt;/p&gt;


	&lt;p&gt;Of course the raw class (called Erlang) can be made asynchronous by wrapping it in a Thread.new which is essentially what the Rulang wrapper class does, but it would be nice to have this built-in. Putting the asynchronous switch in the wrapper class is fine but the wrapper class suffers from a desire to make the Erlang calls feel like ruby and therefore makes calling complicated code impossible through the wrapper and thus makes the asynchronous aspect moot also.&lt;/p&gt;


	&lt;p&gt;The last concern I have is that each class must connect to a node explicitly rather than being able to automatically find and balance between nodes. In order to be happy with the adapter we&amp;#8217;ll have to figure out how to load-balance or make Erlang do it for us.&lt;/p&gt;


	&lt;h2&gt;Conclusion&lt;/h2&gt;


	&lt;p&gt;For the purposes of the the Ruby to Mnesia Adapter I believe that RulangBridge will be sufficient but Erlectricity definitely has its purposes in the Erlang community. Despite some concerns and drawbacks both are usable code and could easily move forward with a little love from the community or follow-up versions by the owners.&lt;/p&gt;


	&lt;p&gt;Any project involving Erlang and Ruby will have to deal extensively with concurrency. Ideally it would be nice to see a broker model between the two that supports communication in both directions and deals with concurrency issues and load-balancing transparently. Until that happens we&amp;#8217;ll have to work with Erlectricity and Rulang and love the creators for their hard work.&lt;/p&gt;</description>
      <pubDate>Wed, 02 Jan 2008 17:25:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:50d75558-ef97-48fd-abdd-155d528c18d3</guid>
      <author>vosechu@create-on.com (Chuck Vose)</author>
      <link>http://www.chuckvose.com/articles/2008/01/02/mnesia-to-ruby-bridge-evaluation</link>
      <category>Ruby</category>
      <category>Mnesia</category>
      <category>Programming</category>
      <category>Erlang</category>
      <category>Ruby</category>
      <category>Erlang</category>
      <category>bridge</category>
      <trackback:ping>http://www.chuckvose.com/articles/trackback/265</trackback:ping>
    </item>
    <item>
      <title>Mnesia + Ruby Announcement</title>
      <description>&lt;p&gt;My goal this year is to release a Ruby port of the Mnesia distributed database and hopefully start the process of moving to a true slice architecture. The port is an interesting project but I think the importance of the slice architecture is paramount.&lt;/p&gt;


	&lt;p&gt;For the last couple of years we&amp;#8217;ve been working on the n-tier model with ruby. It&amp;#8217;s well established and it has been working nicely for us. But the web server industry is starting to move more towards the idea of instances or clouds of ambiguous slices. Amazon is doing it, mongrel is a part of it certainly, Mnesia has always worked this way.&lt;/p&gt;


	&lt;p&gt;My hope is that my port will help us to create an &lt;span class="caps"&gt;EC2&lt;/span&gt; instance that is both the master of it&amp;#8217;s domain and a part of a cloud at the same time. I would like to see an &lt;span class="caps"&gt;EC2&lt;/span&gt; instance that can autoconfigure itself and automatically find its neighbors, which contains a complete Mnesia instance, a couple mongrels, and a proxy/load balancer.&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;m not sure if we can do this quite yet but multi-processor theory suggests that it can be done. Whether it&amp;#8217;s advantageous to remove all the bottle-necks and have to deal with the scheduling individually is where we&amp;#8217;ll have to analyze but I&amp;#8217;m confident that we are moving somewhere truly incredible.&lt;/p&gt;


	&lt;p&gt;In the future I hope to be able to drop in a new &lt;span class="caps"&gt;EC2&lt;/span&gt; and just have it completely figure things out for me. No more MySQL master, no more apache proxying. Whether we use my new port or SimpleDB is of no concern to me at all.&lt;/p&gt;</description>
      <pubDate>Sat, 22 Dec 2007 01:17:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:a94fd9ce-bee4-4caf-b059-6207e3dc5560</guid>
      <author>vosechu@create-on.com (Chuck Vose)</author>
      <link>http://www.chuckvose.com/articles/2007/12/22/mnesia-ruby-announcement</link>
      <category>Ruby</category>
      <category>Mnesia</category>
      <category>Programming</category>
      <category>Erlang</category>
      <category>Mnesia</category>
      <category>Ruby</category>
      <category>Amazon</category>
      <category>EC2</category>
      <category>SimpleDB</category>
      <category>Erlang</category>
      <category>DDBMS</category>
      <category>Distributed</category>
    </item>
    <item>
      <title>find_or_create by params (extension to dynamic attribute based finders)</title>
      <description>&lt;p&gt;Rails has a dynamic method where you can do find_or_create_by_attr_name(attr) but it the method names get incredibly long very quickly. So &lt;span class="caps"&gt;SJS&lt;/span&gt; wrote &lt;a href="http://sami.samhuri.net/2007/4/11/activerecord-base-find_or_create-and-find_or_initialize"&gt;this article&lt;/a&gt; in which he tries to remedy the situation. His solution was pretty elegant but it still only worked for fields that were already defined in the database; if you often redefine setter methods it doesn&amp;#8217;t work at all.&lt;/p&gt;


	&lt;p&gt;Here&amp;#8217;s my attempt to remedy the situation.&lt;/p&gt;


&lt;pre&gt;
module ActiveRecordExtensions
  def self.included(base)
    base.extend(ClassMethods)
  end

  module ClassMethods
    def find_or_create(params)
      begin
        return self.find(params[:id])
      rescue ActiveRecord::RecordNotFound =&amp;gt; e
        attrs = {}

        # search for valid attributes in params
        self.column_names.map(&amp;#38;:to_sym).each do |attrib|
          # skip unknown columns, and the id field
          next if params[attrib].nil? || attrib == :id

          attrs[attrib] = params[attrib]
        end

        # call the appropriate ActiveRecord finder method
        found = self.send("find_by_#{attrs.keys.join('_and_')}", *attrs.values) if !attrs.empty?

        if found &amp;#38;&amp;#38; !found.nil?
          return found
        else
          return self.create(params)
        end
      end
    end
    alias create_or_find find_or_create
  end
end

ActiveRecord::Base.send(:include, ActiveRecordExtensions)
&lt;/pre&gt;

	&lt;h3&gt;Newb instructions&lt;/h3&gt;


	&lt;p&gt;Create a file called active_record_extensions.rb in your the lib directory. Then add `require &amp;#8216;active_record_extensions&amp;#8217;` to your environment.rb at the bottom (without the ``). Restart your server and see what happens!&lt;/p&gt;</description>
      <pubDate>Wed, 12 Sep 2007 22:40:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:4db3f875-4a45-44ae-b887-f86835021ebb</guid>
      <author>vosechu@create-on.com (Chuck Vose)</author>
      <link>http://www.chuckvose.com/articles/2007/09/12/find_or_create-by-params-extension-to-dynamic-attribute-based-finders</link>
      <category>Rails</category>
      <category>Programming</category>
      <category>Rails</category>
      <category>find_or_create</category>
      <category>dynamic</category>
      <category>attribute</category>
      <category>based</category>
      <category>finders</category>
      <category>ActiveRecord</category>
      <category>find</category>
      <category>create</category>
    </item>
    <item>
      <title>Long Bets</title>
      <description>&lt;p&gt;&lt;a href="http://intertwingly.net"&gt;Sam Ruby&lt;/a&gt; occasionally does an article about his long bets and I really respect his ability to predict the future. &lt;a href="http://intertwingly.net/blog/2007/08/12/Long-Bets"&gt;This time&lt;/a&gt; I feel that he was focusing too close and forgot the long part of the &amp;#8216;long bet&amp;#8217;. &lt;span class="caps"&gt;REST&lt;/span&gt; is already important, and there are further developments in edge rails that make it even more important (active resource). MySQL is already a pain for scaling and the plugins are starting to come out but haven&amp;#8217;t really hit the fan yet.&lt;/p&gt;


	&lt;h3&gt;Bet One &amp;#8211; MySQL becomes the exception&lt;/h3&gt;


	&lt;p&gt;First, I think Sam Ruby is dead on about databases. Right now there are only a few things that are a consistent pain for deployment and scaling and databases are the top of the heap. I know there are things like MaxDB for mysql and there are ways to set up ring replication but it&amp;#8217;s hard; something that Ruby&amp;#8217;s community is really good at solving.&lt;/p&gt;


	&lt;p&gt;My first bet is that MySQL dies out for the rails community and something new pops in. It wouldn&amp;#8217;t surprise me if it was &lt;a href="http://www1.erlang.org/documentation/doc-5.0.1/lib/mnesia-3.9.2/doc/index.html"&gt;Mnesia&lt;/a&gt; from &lt;a href="http://www.erlang.se"&gt;Erlang/OTP&lt;/a&gt; or something involving &lt;a href="http://lucene.apache.org/hadoop/"&gt;Hadoop&lt;/a&gt; and &lt;a href="http://wiki.apache.org/lucene-hadoop/Hbase"&gt;HBase&lt;/a&gt;. It would surprise me if &lt;a href="http://www.couchdb.org"&gt;CouchDB&lt;/a&gt; popped onto the scene in a big way but it&amp;#8217;s the sort of thinking that could lead us somewhere interesting. The other option is that someone comes up with a really concrete stack of abstractions that makes it easy to balance mysql requests and writes.&lt;/p&gt;


	&lt;h3&gt;Bet Two &amp;#8211; Rails drops &lt;span class="caps"&gt;REST&lt;/span&gt; completely&lt;/h3&gt;


	&lt;p&gt;Secondly, I think &lt;span class="caps"&gt;REST&lt;/span&gt; is the wrong way to move forward. &lt;span class="caps"&gt;REST&lt;/span&gt; maps very well onto the &lt;span class="caps"&gt;CRUD&lt;/span&gt; principles, but I feel like we very rarely actually use just &lt;span class="caps"&gt;CRUD&lt;/span&gt;. More often than not I want to run custom little things and create crazy associations. And I realize that this is all possible in the &lt;span class="caps"&gt;REST&lt;/span&gt; model, but it makes the controllers obscene sometimes.&lt;/p&gt;


	&lt;p&gt;What we really want is Query Language for the Internet and what better language to build that in than Ruby. I&amp;#8217;ve seen &lt;span class="caps"&gt;DSL&lt;/span&gt;&amp;#8217;s for direct database access and it seems like the routes would be just around the corner if this is where we decide to take it.&lt;/p&gt;


	&lt;p&gt;The question is whether &lt;span class="caps"&gt;DHH&lt;/span&gt; sees the writing on the wall or desperately wants to hang on to &lt;span class="caps"&gt;REST&lt;/span&gt;. Since he&amp;#8217;s put so much effort into the &lt;span class="caps"&gt;REST&lt;/span&gt; idea it seems like he would be loath to drop it, but at the same time he&amp;#8217;s an incredibly mature developer and would hopefully handle a change like this if it ever happened.&lt;/p&gt;


	&lt;h3&gt;Conclusion&lt;/h3&gt;


	&lt;p&gt;All respect to Sam Ruby, I really do respect his predictions over my own. But I think his predictions are too close to us right now. I would like to know what happens after &lt;span class="caps"&gt;REST&lt;/span&gt; and what happens in the database arena.&lt;/p&gt;</description>
      <pubDate>Tue, 11 Sep 2007 23:42:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:048e70f7-20cc-49ba-aac8-3d4bd0f2e433</guid>
      <author>vosechu@create-on.com (Chuck Vose)</author>
      <link>http://www.chuckvose.com/articles/2007/09/11/long-bets</link>
      <category>Rails</category>
      <category>MySQL</category>
      <category>Programming</category>
      <category>REST</category>
      <category>MySQL</category>
      <category>Rails</category>
      <category>Future</category>
      <category>Ruby</category>
      <category>Scaling</category>
      <category>Bets</category>
      <category>Hadoop</category>
      <category>HBase</category>
      <category>Mnesia</category>
      <category>Erlang</category>
      <category>CouchDB</category>
    </item>
    <item>
      <title>Arrow keys in vi and iTerm</title>
      <description>&lt;p&gt;Arrow keys doing funny things when you use vi in iTerm 0.9.5? It&amp;#8217;s because we&amp;#8217;re too used to messing with things. Set your Default bookmark&amp;#8217;s keyboard type back to Global.&lt;/p&gt;


	&lt;p&gt;&amp;#8220;When the terminal type of your sessions is set to one of those &amp;#8220;xterm&amp;#8221; types, iTerm handles the arrow keys, the home key, and the end key in a special way.&amp;#8221; says the &lt;span class="caps"&gt;FAQ&lt;/span&gt; while not actually addressing the solution.&lt;/p&gt;


	&lt;p&gt;But who can complain? Global works well now! Hooray!&lt;/p&gt;</description>
      <pubDate>Thu, 26 Apr 2007 17:25:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:5144455c-345f-4bf7-94ec-b2c971087436</guid>
      <author>vosechu@create-on.com (Chuck Vose)</author>
      <link>http://www.chuckvose.com/articles/2007/04/26/arrow-keys-in-vi-and-iterm</link>
      <category>Programming</category>
      <category>vi</category>
      <category>iTerm</category>
      <category>vim</category>
      <category>arrow</category>
      <category>keys</category>
      <category>keyboards</category>
    </item>
    <item>
      <title>Testing rails without fixtures</title>
      <description>&lt;p&gt;At &lt;a href="http://www.create-on.com"&gt;On &amp;#38; On Creative&lt;/a&gt; we have a lot of sites on a common rails backend. It&amp;#8217;s incredibly flexible so we can offer a lot of support to customers but because there are so many customers with different needs testing has become a huge pain. Not only does it let us run tests custom to each client, it provides a way to import the data to the test db really easily and it&amp;#8217;s way faster than loading the fixtures each time you start a test. Yay!&lt;/p&gt;


	&lt;p&gt;After googling around I happened upon &lt;a href="http://blog.caboo.se/articles/2007/2/13/what-about-those-bloated-tests"&gt;this caboo.se article&lt;/a&gt; about how to run without fixtures at all. It&amp;#8217;s a very indepth article with lots of good things in it; far be it for me to try to compete.&lt;/p&gt;


	&lt;p&gt;Instead, here&amp;#8217;s the low down on how we prepare each of our sites for testing.&lt;/p&gt;


	&lt;p&gt;Add the following to the end of your rails_root Rakefile:&lt;/p&gt;


&lt;code&gt;
class Rake::Task
  def detract(prerequisite)
    @prerequisites.delete(prerequisite)
  end
end

%w(units functionals integration recent uncommitted).each do |task|
  Rake::Task["test:#{task}"].detract('db:test:prepare')
  Rake::Task["test:#{task}"].enhance(['environment'])
end
&lt;/code&gt;

	&lt;p&gt;Add the following to lib/tasks/fixtures.rake. Make sure to look at the two commented lines:&lt;/p&gt;


&lt;code&gt;
# This code courtesy of the "Rails Recipe's book":http://www.pragmaticprogrammer.com/titles/fr_rr/ I believe. 
namespace :db do
  namespace :fixtures do

    desc 'Create YAML test fixtures from data in an existing database. Defaults to development database. Set RAILS_ENV to override.'
    task :dump =&amp;gt; :environment do
      # Remove the limit if you want to. It's a timesaver mostly
      sql  = "SELECT * FROM %s LIMIT 0,1000" 
      # Add tables you don't want dumped. 
      skip_tables = ["schema_info", "plugin_schema_info", "engine_schema_info", "sessions"]
      ActiveRecord::Base.establish_connection(:development)
      (ActiveRecord::Base.connection.tables - skip_tables).each do |table_name|
        i = "000" 
        File.open("#{RAILS_ROOT}/test/fixtures/#{table_name}.yml", 'w') do |file|
          data = ActiveRecord::Base.connection.select_all(sql % table_name)
          file.write data.inject({}) { |hash, record|
            hash["#{table_name}_#{i.succ!}"] = record
            hash
          }.to_yaml
        end
      end
    end
  end
end
&lt;/code&gt;

	&lt;p&gt;Then the fun easy stuff happens:&lt;/p&gt;


&lt;code&gt;
rake db:fixtures:dump RAILS_ENV=production
rake db:fixtures:load RAILS_ENV=test
rake test:plugins PLUGIN=your_plugin
&lt;/code&gt;

	&lt;p&gt;If you want to commit the fixtures to the repo you can but it seems a waste to me since you might be regenerating them often.&lt;/p&gt;


	&lt;p&gt;Also, check the two comments in the fixtures.rake, it could be doing things you don&amp;#8217;t expect.&lt;/p&gt;</description>
      <pubDate>Wed, 25 Apr 2007 16:21:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:d02a27e0-93c9-4fc0-8819-8c41a2e2f22d</guid>
      <author>vosechu@create-on.com (Chuck Vose)</author>
      <link>http://www.chuckvose.com/articles/2007/04/25/testing-rails-without-fixtures</link>
      <category>Rails</category>
      <category>Programming</category>
      <category>Rails</category>
      <category>rake</category>
      <category>plugins</category>
      <category>fixtures</category>
      <category>testing</category>
    </item>
    <item>
      <title>Sending messages to all users</title>
      <description>&lt;p&gt;One of the biggest fears of all system admins and developers is publishing work to a live server and having it break everything. Naturally we all go to great lengths to make sure this doesn&amp;#8217;t happen but even the most well-tested code in the simplest environment still breaks sometimes.&lt;/p&gt;


	&lt;p&gt;In addition to these fatalities is the less intrusive but equally damning maintenance that sometimes just has to happen in the middle of the day whether there&amp;#8217;s users in the system or not. I&amp;#8217;m sure you can think of a few scenarios and horror stories.&lt;/p&gt;


	&lt;p&gt;At any rate I&amp;#8217;ve come to realize that it&amp;#8217;s extremely important to be able to tell the people in the system that things are going to break for a bit. This is fortunately extremely easy in Rails; a quick three or four lines in the application.rb will do it. In &lt;span class="caps"&gt;PHP&lt;/span&gt; it&amp;#8217;s easy if there is even a little planning that went into the project.&lt;/p&gt;


	&lt;p&gt;Despite the ease I don&amp;#8217;t think this is very common in the world of small-to-medium businesses and this seems like a shame.&lt;/p&gt;


	&lt;p&gt;Letting your users know what&amp;#8217;s about to happen or what happened a moment ago will increase their sense of security in many cases and in the very least will keep them from calling you in a panic.&lt;/p&gt;


	&lt;p&gt;Blissful silence.&lt;/p&gt;</description>
      <pubDate>Mon, 08 May 2006 03:19:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:eb629f67-bbc4-437c-90e2-1cae6659e6e8</guid>
      <author>vosechu@create-on.com (Chuck Vose)</author>
      <link>http://www.chuckvose.com/articles/2006/05/08/sending-messages-to-all-users</link>
      <category>Programming</category>
      <trackback:ping>http://www.chuckvose.com/articles/trackback/6</trackback:ping>
    </item>
    <item>
      <title>Subversion</title>
      <description>&lt;p&gt;I&amp;#8217;m finally learning, oh yes.&lt;/p&gt;


	&lt;p&gt;The reason &lt;span class="caps"&gt;IDE&lt;/span&gt;&amp;#8217;s make it so difficult to copy folders around is because it&amp;#8217;s an incredibly difficult process. In order to copy in Subversion you have to copy the folders/files, delete any .svn directories in each level of a folder, then those folders/files have to be added to the repo.&lt;/p&gt;


	&lt;p&gt;Very complicated process which has been killing me lately. I should have known better; how not &lt;span class="caps"&gt;DRY&lt;/span&gt; of me to copy a folder&amp;#8230;&lt;/p&gt;</description>
      <pubDate>Fri, 21 Apr 2006 10:32:28 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:74fa293b-8ecb-41fd-8422-f8d404ab9ab6</guid>
      <author>vosechu@create-on.com (Chuck Vose)</author>
      <link>http://www.chuckvose.com/articles/2006/04/21/subversion</link>
      <category>Programming</category>
      <trackback:ping>http://www.chuckvose.com/articles/trackback/4</trackback:ping>
    </item>
    <item>
      <title>Why Do Unit Tests Exist?</title>
      <description>&lt;p&gt;Holy crap I finally figured out why unit tests exist! To give me something to think about in the shower. Yep, simple as that.&lt;/p&gt;


	&lt;p&gt;No, wait, there are two really good uses off the top of my head: packaging and testing filesystem crap.&lt;/p&gt;


	&lt;p&gt;The first use is if you&amp;#8217;re exporting a plugin for later use (or for general distribution). In this scenario there&amp;#8217;s a fairly good chance that the user importing your plugin has messed up their install or is using a database that isn&amp;#8217;t the same version or even the same type as the one you&amp;#8217;re using.&lt;/p&gt;


	&lt;p&gt;In either case if you have unit tests and none of them fail then you know that the database probably isn&amp;#8217;t at fault.&lt;/p&gt;


	&lt;p&gt;The second use is for filesystem crap. I can still count the number of times I&amp;#8217;ve messed up the permissions on a folder only to find it after a half hour of debugging. This should never happen and there are wonderful tools to prevent it. `ri File` and `ri FileUtils` should get you started if you&amp;#8217;re curious.&lt;/p&gt;


	&lt;p&gt;Specifically I&amp;#8217;ve been working on a photo upload admin because I don&amp;#8217;t understand file_column. In this I occasionally have to make a directory (okay, every time I upload something that isn&amp;#8217;t a graphic) and it would be really nice to know that when I post it onto our production server that it&amp;#8217;ll work when I release it into the wild.&lt;/p&gt;


	&lt;p&gt;Under this column is a wonderful addition to test_helper to check that things are correctly set in other places. Since rake is seperate from the dispatchers it could check their permissions, check the permissions of the public and log folders, and a myriad of other wonderful tests that could help newbies get on their way.&lt;/p&gt;


	&lt;p&gt;Rake is already pretty good at this but it serves as an excellent example of one use for unit testing.&lt;/p&gt;</description>
      <pubDate>Thu, 20 Apr 2006 14:39:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:00413d6b-6d4e-4689-b5ea-670aa1b4a648</guid>
      <author>vosechu@create-on.com (Chuck Vose)</author>
      <link>http://www.chuckvose.com/articles/2006/04/20/why-do-unit-tests-exist</link>
      <category>Rails</category>
      <category>Programming</category>
      <trackback:ping>http://www.chuckvose.com/articles/trackback/3</trackback:ping>
    </item>
  </channel>
</rss>
