<?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/"
	>

<channel>
	<title>thyncology &#187; Ruby &amp; Rails</title>
	<atom:link href="http://www.thynctank.com/category/ruby-rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thynctank.com</link>
	<description>The Science of Thynctank.</description>
	<lastBuildDate>Sun, 19 Jun 2011 04:33:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>SafariWatir Nuisances</title>
		<link>http://www.thynctank.com/ruby-rails/2009/03/safariwatir-nuisances/</link>
		<comments>http://www.thynctank.com/ruby-rails/2009/03/safariwatir-nuisances/#comments</comments>
		<pubDate>Thu, 05 Mar 2009 06:04:34 +0000</pubDate>
		<dc:creator>thynctank</dc:creator>
				<category><![CDATA[Ruby & Rails]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[front end]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[watir]]></category>

		<guid isPermaLink="false">http://www.thynctank.com/?p=157</guid>
		<description><![CDATA[The place where I work (RideCharge) is a Rails shop. As such, we&#8217;ve embraced numerous Ruby technologies, including several ActiveRecord plugins, test frameworks, and other components used at various points in the stack. I deal with a lot of view-side and presentational stuff, including having embraced Sass for stylesheets (I even use them in some [...]]]></description>
			<content:encoded><![CDATA[<p>The place where I work (<a href="http://www.ridecharge.com">RideCharge</a>) is a Rails shop. As such, we&#8217;ve embraced numerous Ruby technologies, including several ActiveRecord plugins, test frameworks, and other components used at various points in the stack. I deal with a lot of view-side and presentational stuff, including having embraced Sass for stylesheets (I even use them in some non-Rails/Ruby projects via CLI), making use of AssetPackager and so on.</p>

<p>One thing RideCharge has used, but which I&#8217;ve only recently expressed interest in, is Watir. Watir is a cool testing toolkit that allows you to control and get feedback from various Web browsers using Ruby. You can use it, or variations of it, with IE (the original Watir was IE-only) Firefox, Safari, or even Flash using the various <a href="http://wtr.rubyforge.org/platforms.html">variations</a>. I&#8217;ve only spent enough time with it to get it installed and tinker a bit, so this post only deals with real in-the-field experience. As such, I&#8217;ve only played with the FireWatir and SafariWatir variations.</p>

<p>One thing I&#8217;ve noticed already are some nuisances in SafariWatir and FireWatir, and perhaps Watir in general in some cases:</p>

<ul>
<li>SafariWatir&#8217;s <code>goto</code> method requires the protocol as part of the URL whereas FireWatir does not. This is a minor complaint.</li>
<li>Links in SafariWatir appear to have no href or url property (among others), despite <a href="http://wiki.openqa.org/display/WTR/Methods+supported+by+Element">this table</a> showing that they should.</li>
<li>SafariWatir has no url to determine the current page.</li>
<li>No support for CSS selectors that I&#8217;m aware. This could be brought in from one of at least two Ruby projects (<a href="http://wiki.github.com/why/hpricot">Hpricot</a> or <a href="http://github.com/tenderlove/nokogiri/tree/master">Nokogiri</a>). XPath is a bore.</li>
<li>Confusingly it only selects the first matching element if multiple elements match. There&#8217;s no way to verify the # of elements, etc. Selecting a different matching element is accomplished through the <code>:index</code> parameter.</li>
<li>Having a different &#8220;selector&#8221; method for almost every element type seems strange, but perhaps this is just bias from having used JavaScript selector engines so much.</li>
<li>Having the browser &#8220;click&#8221; a link where JavaScript is supposed to intercept the click fails to trigger the JavaScript, or may simply have no effect (in one case in SafariWatir).</li>
<li>No convenient &#8220;click the back button&#8221; method. This would be useful for testing state-saving in Ajax-focused applications where browser history is an issue.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.thynctank.com/ruby-rails/2009/03/safariwatir-nuisances/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Thoughts on ThyncRecord</title>
		<link>http://www.thynctank.com/javascript/2008/09/thoughts-on-thyncrecord/</link>
		<comments>http://www.thynctank.com/javascript/2008/09/thoughts-on-thyncrecord/#comments</comments>
		<pubDate>Thu, 04 Sep 2008 05:27:20 +0000</pubDate>
		<dc:creator>thynctank</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Ruby & Rails]]></category>
		<category><![CDATA[activerecord]]></category>
		<category><![CDATA[adobe air]]></category>
		<category><![CDATA[air]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[jazzrecord]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[sqlite]]></category>
		<category><![CDATA[thyncrecord]]></category>

		<guid isPermaLink="false">http://www.thynctank.com/?p=94</guid>
		<description><![CDATA[This is a reposting of an email I sent Frank Lee, who I&#8217;ve tapped to help out in building optimized queries for ThyncRecord. Just figured I&#8217;d share. &#8220;Because of [JavaScript's prototype-based inheritance vs normal OOP], there is no proper concept of class methods and instance methods. (I don&#8217;t believe moo has implemented such a feature [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_95" class="wp-caption aligncenter" style="width: 509px"><a href="http://www.thynctank.com/wp/wp-content/uploads/2008/09/thyncrecord-diagram.png"><img class="size-full wp-image-95" title="thyncrecord-diagram" src="http://www.thynctank.com/wp/wp-content/uploads/2008/09/thyncrecord-diagram.png" alt="Control Diagram for ThyncRecord" width="499" height="386" /></a><p class="wp-caption-text">Control Diagram for ThyncRecord</p></div>

<p>This is a reposting of an email I sent Frank Lee, who I&#8217;ve tapped to help out in building optimized queries for ThyncRecord. Just figured I&#8217;d share.</p>

<p>&#8220;Because of [JavaScript's prototype-based inheritance vs normal OOP], there is no proper concept of class methods and instance methods. (I don&#8217;t believe moo has implemented such a feature yet, though it may in the future&#8230;) So, whereas in ActiveRecord&#8217;s Ruby implementation we have a model class which returns instances of itself when queried using class methods, I&#8217;ve had to invoke a second class called Record, which is a mostly dumb object with a few key methods (save, destroy, reload) and access to associated records within the database. To accomplish this, we need to preload data as deep as seems reasonable to obtain quickly and map it out to dynamically-generated objects which are then assigned to the associated properties.</p>

<p>To generate the SQL for a query, it is necessary to examine a particular model&#8217;s associations and the associated models&#8217; associations, recursively until we reach the appropriately-defined depth. It is of course also necessary to know the data type for each column of the currently-being-built object, It is most important to know upon save, preventing improper types being stored in the db, formatting the query strings appropriately with quotes or without, outputting error messaging, etc. Likewise validation rules may output similar error messaging, as defined by the user of the library via regex. (may implement add&#8217;l validation in the future)</p>

<p>Associations which can be defined should include at a minimum: belongs<em>to and has</em>one, which are essentially the same thing but seen from different perspectives; has<em>many, which maps an array of the associated model&#8217;s Records to a plural property name on the root Record object; and has</em>and<em>belongs</em>to_many, which will map an array of associated Records from either end. Determining where to cutoff preloading of these properties is a significant decision to make still. Preventing circular references, etc may be important.</p>

<p>Data types need further fleshing out as well, I currently have only been dealing with number and text, since SQLite does little to prevent storing improper types in the db. (it does, however, provide some base functions which may be used to provide some additional validation beyond application-level if we thought it was necessary) Likewise, JavaScript makes type checking harder than it is in most languages. We certainly should at a minimum include a date type of some kind, I believe SQLite has another built-in function for current timestamp, etc&#8230;</p>

<p>An example of ThyncRecord usage would be storing various users&#8217; payment info. We might define a User model and a PaymentMethod model, where the User has<em>many PaymentMethods, and a PaymentMethod belongs</em>to a User. All of this is accomplished declaratively (along with defining all columns and add&#8217;l validation). Schema is created by means of migrations or model declarations alone. (I may also implement the Rails concept of fixtures which will load data directly into the db from formatted text, in this case JSON) A call to return the second payment type for user 3 might be:
<pre lang="javascript">var payment<em>meth = User.find(3).payment</em>methods[1];</pre>
Let&#8217;s also presume that this new object is assigned an ID of 543, (it&#8217;s record 543 in the payment<em>methods table) though the user needs not know of this. You might then update the billing address (a text field) of this payment method (we can assume it&#8217;s a credit card, perhaps):
<pre lang="javascript">payment</pre></em>meth.billing<em>address = "123 Some Place, Sometown, ZZ 90876";
payment</em>meth.save();
Calling save will first verify that some data has changed from the initially-loaded state, and if it has it will pass over into the validation process for any sub-objects first, then on to the current Record. In this case we have no sub-objects, only a text field to worry about. It should write out something like
<pre lang="sql">"UPDATE payment<em>methods SET billing</em>address='123 Some Place, Sometown, ZZ 90876' WHERE id=543";</pre>
The Record object passes back the updated data to its corresponding Model (all Records contain a key to the master models hash stored in ThyncRecord for the purposes of navigating through associations).&#8221;</p>

<p>Anybody w/ questions or who feels like contributing, feel free to email me (<a href='mailto:&#116;&#104;&#121;&#110;&#99;&#116;&#97;&#110;&#107;&#64;&#116;&#104;&#121;&#110;&#99;&#116;&#97;&#110;&#107;&#46;&#99;&#111;&#109;'>&#116;&#104;&#121;&#110;&#99;&#116;&#97;&#110;&#107;&#64;&#116;&#104;&#121;&#110;&#99;&#116;&#97;&#110;&#107;&#46;&#99;&#111;&#109;</a>).</p>

<p>[EDIT: ThyncRecord is now JazzRecord and will be available for download from <a title="JazzRecord - Mmm Mmm Good!" href="http://www.jazzrecord.org/">www.jazzrecord.org</a> starting 10/21/08]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thynctank.com/javascript/2008/09/thoughts-on-thyncrecord/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Hooyip Choices, Poppy&#8217;s Passing</title>
		<link>http://www.thynctank.com/ruby-rails/2007/10/hooyip-choices-poppys-passing/</link>
		<comments>http://www.thynctank.com/ruby-rails/2007/10/hooyip-choices-poppys-passing/#comments</comments>
		<pubDate>Wed, 03 Oct 2007 20:28:44 +0000</pubDate>
		<dc:creator>thynctank</dc:creator>
				<category><![CDATA[Ruby & Rails]]></category>
		<category><![CDATA[akai]]></category>
		<category><![CDATA[file_uploads]]></category>
		<category><![CDATA[hobo]]></category>
		<category><![CDATA[mp3s]]></category>
		<category><![CDATA[poppy]]></category>
		<category><![CDATA[widgets]]></category>

		<guid isPermaLink="false">http://www.thynctank.com/rails/2007/10/hooyip-choices-poppys-passing/</guid>
		<description><![CDATA[So we&#8217;ve got the basic schema and business logic behind validation of and connection between models in Hooyip. After a few more minor details we&#8217;ll be ready to build the front-end in earnest. Those choices are basically regarding ID3 handling and file uploads. Aside from picking from the numerous .swf-based JavaScript uploader widgets (see here, [...]]]></description>
			<content:encoded><![CDATA[<p>So we&#8217;ve got the basic schema and business logic behind validation of and connection between models in <strong>Hooyip</strong>. After a few more minor details we&#8217;ll be ready to build the front-end in earnest.</p>

<p>Those choices are basically regarding ID3 handling and file uploads. Aside from picking from the numerous .swf-based <strong>JavaScript uploader widgets</strong> (see <a href="http://swfupload.mammon.se/" title="SWFUpload">here</a>, and <a href="http://digitarald.de/project/fancyupload/" title="FancyUpload">here</a>) we&#8217;ve got to determine the back-end stuff. So I&#8217;m currently planning on using <strong>id3.rb</strong> (download <a href="http://www.unixgods.org/~tilo/Ruby/ID3.tar.gz" title="id3.rb">here</a>), which is apparently alternately known as &#8220;ID3 Library for Ruby&#8221;, &#8220;id3tag&#8221;, and who knows what else. While documentation seems sparse, the functionality is promising. I&#8217;m going to add to it/wrap it a li&#8217;l bit just so I don&#8217;t have to jump through so many hoops and can handle all mp3s the same regardless of tag version. For some reason development stopped back in 2004, according to what I can find online. This lib was simply <strong>more accessible</strong> and easier to install than the alternatives. (which I could only find references to <a href="http://raa.ruby-lang.org/cat.rhtml?category_major=Library;category_minor=MP3" title="Ruby mp3 whatzits">here</a>)</p>

<p><span id="more-49"></span>
I&#8217;ve also made the decision to <strong>store our users&#8217; mp3s in the db vs. in flat files</strong>, primarily as a matter of convenience. I can&#8217;t imagine having to manage thousands of files in hundreds (or thousands) of directories, and all of the maintenance nightmares if we decided to change the file structure. <strong>Storing in the db just makes sense</strong>. Now I just have to remember to make use of persistent connections!</p>

<p><strong>Dropping Hobo and DRYML (at least for the time being)</strong></p>

<p>Hobo is a great-looking toolkit andÂ  I&#8217;m sure I&#8217;ll make use of it in the future. However, it&#8217;s got a steep learning curve and has a lot of bells and whistles I just don&#8217;t think I need for Hooyip. It&#8217;s also not been the fastest kid on the block in terms of parsing over my DRYML files, and I&#8217;ve only got a few. Instead of Hobo, <strong>I&#8217;m turning to <a href="http://haml.hamptoncatlin.com/" title="Haml">Haml</a></strong>, another plugin I may have mentioned in the past. This plug <strong>uses a simplified markup syntax that borrows from CSS</strong> and still allows for dynamic content (and Rails helpers) quite easily. A companion language, <strong>Sass, minimizes complexity of CSS and enforces bundling together of parent-child selector groups</strong>.Â  Haml has performed excellently in my brief trials, and is quite simple to install. There are also great Haml/Sass editors popping up all over for Eclipse (point your Eclipse updater <a href="http://haml.lucky-dip.net/" title="Haml Update Site">here</a>) and TextMate bundles, etc.</p>

<p><strong>Akai is back</strong>! More dog pictures for all the fiends out there in a minute. He was away while my great aunt Mar was in town, as she&#8217;s fantastically allergic to anything and everything. But no food allergies, go figure. Now on to the reason for Akai&#8217;s departure and Mar&#8217;s arrival&#8230;</p>

<p>Sad news I figure comes best last, and I have to report that my grandfather, <strong>Theodore Patrick McFadden, also known as Poppy, has passed away at 88</strong>. I don&#8217;t really have much to say about the topic in the blog, just wanted to actually write it somewhere and let it be known that <strong>we all miss him</strong>. I was one of his pallbearers. Thanks to all of the friends who came to the funeral and/or mass, (regardless of how religious you may be&#8230; I sure am not) that was real classy and very much appreciated by all.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thynctank.com/ruby-rails/2007/10/hooyip-choices-poppys-passing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nutech, ad nauseum</title>
		<link>http://www.thynctank.com/ruby-rails/2007/07/nutech-ad-nauseum/</link>
		<comments>http://www.thynctank.com/ruby-rails/2007/07/nutech-ad-nauseum/#comments</comments>
		<pubDate>Mon, 30 Jul 2007 19:47:00 +0000</pubDate>
		<dc:creator>thynctank</dc:creator>
				<category><![CDATA[Ruby & Rails]]></category>
		<category><![CDATA[aptana]]></category>
		<category><![CDATA[cake]]></category>
		<category><![CDATA[hobo]]></category>
		<category><![CDATA[jedit]]></category>
		<category><![CDATA[migrations]]></category>
		<category><![CDATA[migration_tool]]></category>
		<category><![CDATA[new-job]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[project_tracker]]></category>
		<category><![CDATA[relational_mapping]]></category>

		<guid isPermaLink="false">http://www.thynctank.com/rails/2007/07/nutech-ad-nauseum/</guid>
		<description><![CDATA[Well, I&#8217;ve been playing with Rails a bit more at work now, building a project tracker system for internal use. It&#8217;s been a great learning experience, however little time I&#8217;ve had to spend on it, and I believe my relational mapping skills have come around on it. I&#8217;ve learned how important it is to plan [...]]]></description>
			<content:encoded><![CDATA[<p>Well, I&#8217;ve been playing with Rails a bit more at work now, building a project tracker system for internal use. It&#8217;s been a great learning experience, however little time I&#8217;ve had to spend on it, and I believe my relational mapping skills have come around on it. I&#8217;ve learned how important it is to plan the relationships/models before ever implementing views or even controller logic. The Rails console came in <em>very</em> handy in figuring out relationships when they weren&#8217;t readily apparent, as well as for generating one-off test data. (Haven&#8217;t got around to proper unit testing, nor will I on this project as I haven&#8217;t got time&#8230; but I plan on getting into that) Migrations are not the funnest things to write, and sorting through them to find your current list of all columns for a given model can be a major pain&#8230; as can flipping back and forth between your SQL manager of choice and your model files in developing the relationships. (as has been pointed out in the article I&#8217;m about to link to, all of this data is available in schema.rb, but that&#8217;s a longish file and not the optimal way to go about reading off information about a single model/table)</p>

<p>Other stuff and nonsense after the jump&#8230;</p>

<p><span id="more-45"></span>
So when writing migrations gets you down, know that just around the corner is a whole <strong>new</strong> sexy <a href="http://hobocentral.net/blog/2007/07/06/so-long-migrations/" title="Hobo Migration Generator!" target="_blank">migration tool</a> from Tom at Hobo Central. Tom is responsible for the current &#8220;sexy migrations&#8221; trend in Rails and has some amazing ideas. The new tool allows you to define all columns <em>and</em> relationships within the models themselves, and based upon the comparison between current models and previous schema, the migration generator migration files to do all the work of both up <em>and</em> down methods! That&#8217;s right, no more typing redundant  code which is just a mirror of the previous method def! I&#8217;d love to see this implemented in core Rails. Let us pray&#8230;</p>

<p>There are no books specifically on CakePHP. Not a single one. So whoever writes the first few books will probably make out pretty well in royalties for a while! Hint, Hint! I may write one myself if I ever get round to learning it that well before it takes off!</p>

<p>On the PHP front, Aptana has now <a href="http://www.aptana.com/blog/?p=163" title="PHP in Aptana" target="_blank">added PHP support</a> to the nightly build! Yeehaw! Abandon all PDT and PHP Eclipse, ye who enjoy the Aptana Experience!</p>

<p>Another recent IDE/editor interest of mine (other than TextMate&#8230; drool) is <a href="http://jedit.org" title="jEdit - Free, Open Source coolness" target="_blank">jEdit</a>. With the Ruby plugin, SuperAbbrevs, TextAutocomplete and a few other choice plugins (all freely available and without any additional Web browsing to retrieve) jEdit can pose as a fairly capable TextMate replacement. I&#8217;d mentioned this in a previous blog entry or two, but I&#8217;m really coming to love this editor. The fact that it has Ruby/Rails documentation as you type (as well as dictionary-based code completion) has had me using it over TextMate for Rails for the time being. (I&#8217;m not as used to Rails code as I&#8217;d like to be, yet) Now that I&#8217;ve added the other two plugs (SuperAbbrevs and TextAutocomplete) I have most of what was missing coming from a TextMate background. (snippet templates and completion of previously-typed words) Very much looking forward to going ever deeper with this tool.</p>

<p>I&#8217;ve got a new job! <a href="http://www.hanleywood.com/" title="Hanley Wood" target="_blank">Hanley Wood</a> publish a few dozen magazines for the construction marketplace, and I&#8217;ll be part of their dev team working on a massive CMS to manage all of these sites. Very exciting.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thynctank.com/ruby-rails/2007/07/nutech-ad-nauseum/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.458 seconds -->

