<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"><channel><title>Disqus - Latest Comments for Dan Kubb</title><link>http://disqus.com/people/63b22ac9bff0cd55d8a91da4dbf00693/</link><description></description><language>en</language><lastBuildDate>Sat, 29 Nov 2008 12:30:44 -0000</lastBuildDate><item><title>Re: [ANN] alter-ego 1.0.0 Released</title><link>http://virtuouscode.disqus.com/ann_alter_ego_100_released/#comment-4062043</link><description>This looks pretty nice.  I was curious tho, have you looked at Mixology?  I was thinking that the state blocks could setup anonymous modules, and instead of the handle blocks you could use normal methods.  Each module would correspond to a specific state and get mixed into the object as part of each state transition.</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Dan Kubb</dc:creator><pubDate>Sat, 29 Nov 2008 12:30:44 -0000</pubDate></item><item><title>Re: The last of the Merb 0.5.x line</title><link>http://gweezlebur.disqus.com/the_last_of_the_merb_05x_line/#comment-4911620</link><description>Mike, a good resource to check merb against for its HTTP compliance is the following flow chart:&lt;br&gt;&lt;br&gt;  &lt;a href="http://thoughtpad.net/alan-dean/http-headers-status.html" rel="nofollow"&gt;http://thoughtpad.net/alan-dean/http-headers-st...&lt;/a&gt;&lt;br&gt;&lt;br&gt;It gives alot of information about how requests should be handled, and what status codes to return in certain situations.  Its missing a few things, like returning 422 Unprocessable Entity when a PUT or POST request body is well formed, but contains invalid information (Fielding commented in rest-discuss this was the best status to return in this case); otherwise its probably one of the best resources aside from RFC 2616.</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Dan Kubb</dc:creator><pubDate>Sat, 02 Feb 2008 12:35:00 -0000</pubDate></item><item><title>Re: Easy PDF Generation with Ruby, Rails, and HTMLDOC</title><link>http://adsblog.disqus.com/easy_pdf_generation_with_ruby_rails_and_htmldoc/#comment-20755838</link><description>Would you mind posting an example of what the example view renders to when rendered as PDF?&lt;br&gt;&lt;br&gt;I've got some code using PDF::Writer, and managing the templates is a pain.  If I could design the templates using normal HTML views, and then render them as PDF with some reasonable control over the style, I'd be a happy man.</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Dan Kubb</dc:creator><pubDate>Tue, 20 Nov 2007 15:33:02 -0000</pubDate></item><item><title>Re: Quick trick for using &amp;#8220;classify&amp;#8221;</title><link>http://adsblog.disqus.com/quick_trick_for_using_8220classify8221/#comment-20755965</link><description>Have you thought about submitting a failing test case to the Rails Trac site?  I can imaging that tables with the word "status" would be reasonably common, so it probably should be fixed.</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Dan Kubb</dc:creator><pubDate>Sun, 24 Feb 2008 16:23:51 -0000</pubDate></item><item><title>Re: Battle Royale - Testing</title><link>http://giantrobots.disqus.com/battle_royale_testing/#comment-14585167</link><description>&lt;p&gt;This is a great post.  I tend to mock too far in depth, and I think I should just be testing the surface of my API and try to treat it more like a black box so that my tests aren&amp;#8217;t brittle.&lt;/p&gt;&lt;br&gt;&lt;br&gt;&lt;p&gt;I know your testing helpers aren&amp;#8217;t finished, but I have a question about the syntax.  In your tests I see the following:&lt;/p&gt;&lt;br&gt;&lt;br&gt;&lt;code&gt;&lt;br&gt;should_have_many :rated_books, :through =&amp;gt; :ratings&lt;br&gt;&lt;/code&gt;&lt;br&gt;&lt;br&gt;&lt;p&gt;For the purposes of testing does it really matter if rated_books is found through ratings?  It might only be better to make sure that User#rated_books can be responded to, returns zero, one or more RatedBook models, and whatever other behaviour the dependent code relies upon.&lt;/p&gt;&lt;br&gt;&lt;br&gt;&lt;p&gt;The fact that the models are found through a join with another model isn&amp;#8217;t really important (IMHO) to test.  If you were ever to change this, but leave the interface the same, all dependent code shouldn&amp;#8217;t break, but the tests will.&lt;/p&gt;&lt;br&gt;&lt;br&gt;&lt;p&gt;I think when tests break but dependent code doesn&amp;#8217;t that means the test cases are too brittle.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Dan Kubb</dc:creator><pubDate>Sun, 18 Mar 2007 13:50:00 -0000</pubDate></item><item><title>Re: Battle Royale - Testing</title><link>http://giantrobots.disqus.com/battle_royale_testing/#comment-14585177</link><description>&lt;p&gt;Tammer: Actually I don&amp;#8217;t think that using reflection is such a bad way of testing the associations, as long as the logic is wrapped up nicely and can be updated in one spot should the reflection API in ActiveRecord change at some point.  ActiveRecord is pretty well tested, so as long as its API says the association exists I think its reasonable to believe it.&lt;/p&gt;&lt;br&gt;&lt;br&gt;&lt;p&gt;I&amp;#8217;ve been thinking about the problem of over-mocking, and I just came across a presentation by Chad Fowler called &lt;a href="http://video.google.com/videoplay?docid=-5067787434087643104&amp;#38;hl=en-GB" rel="nofollow"&gt;&amp;#8216;Quick and Clean: Well-factored Rails&amp;#8217;&lt;/a&gt; that presents a few approaches that I think would simplify controller testing.  Here&amp;#8217;s a &lt;a href="http://www.luisdelarosa.com/2007/03/05/quick-and-clean-rails-code-by-chad-fowler-a-summary/" rel="nofollow"&gt;summary of his talk&lt;/a&gt; as well.&lt;/p&gt;&lt;br&gt;&lt;br&gt;&lt;p&gt;For example, he asserts that you don&amp;#8217;t want to have finder methods with conditions/orders in your controller actions such as:&lt;p&gt;&lt;br&gt;&lt;br&gt;&lt;code&gt;&lt;br&gt;&lt;code&gt;&lt;br&gt;def search&lt;br&gt;  @users = User.find :all, :conditions =&amp;gt; ['name like ?', "%#{params[:q]}%"]&lt;br&gt;end&lt;br&gt;&lt;/code&gt;&lt;br&gt;&lt;/code&gt;&lt;br&gt;&lt;br&gt;&lt;p&gt;Instead he thinks the controller should have no knowledge of how the &lt;code&gt;User.find&lt;/code&gt; method works, and that you should wrap it into a finder method like&lt;br&gt;&lt;code&gt;User.search_by_name&lt;/code&gt;, as in your example above:&lt;br&gt;&lt;br&gt;&lt;code&gt;&lt;br&gt;&lt;code&gt;&lt;br&gt;def search&lt;br&gt;  @users = User.search_by_name(params[:q])&lt;br&gt;end&lt;br&gt;&lt;/code&gt;&lt;br&gt;&lt;/code&gt;&lt;br&gt;&lt;br&gt;&lt;p&gt;This is also known as the &lt;a href="http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model" rel="nofollow"&gt;Skinny Controller, Fat Model&lt;/a&gt; approach.&lt;/p&gt;&lt;br&gt;&lt;br&gt;&lt;p&gt;If this was used then to test the search controller action, all you&amp;#8217;d have to do is mock &lt;code&gt;User.search_by_name&lt;/code&gt; in your functional test.  You&amp;#8217;d still want to test &lt;code&gt;User.search_by_name&lt;/code&gt; directly in the unit test, which is sort of just like moving the complexity to a different spot, although I think its moving it to the more correct location.&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Dan Kubb</dc:creator><pubDate>Mon, 19 Mar 2007 23:56:00 -0000</pubDate></item><item><title>Re: Jester: JavaScriptian REST</title><link>http://giantrobots.disqus.com/jester_javascriptian_rest/#comment-14585450</link><description>&lt;p&gt;Eric, this is absolutely fantastic.  This (and a few other cool things this week) is enough to get me to switch back to Prototype.&lt;/p&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;	&lt;p&gt;+1 for an async option too.&lt;/p&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;	&lt;p&gt;Also, you may want to look at the bottom of ActiveResource&amp;#8217;s README file for a list of error codes a RESTful Rails app can return.  I believe the status codes Jester is checking aren&amp;#8217;t quite in-line with ARs&amp;#8217; behaviour.&lt;br&gt;For example a status between 200-399 is considered to not have returned an error, while 422 is used when the app receives bad data.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Dan Kubb</dc:creator><pubDate>Sun, 08 Apr 2007 13:02:00 -0000</pubDate></item><item><title>Re: Jester 1.1: Asynchronous REST</title><link>http://giantrobots.disqus.com/jester_11_asynchronous_rest/#comment-14585577</link><description>&lt;p&gt;Is anyone working on Rails helpers that use Jester for things like AutoComplete?  It seems as if the built-in Rails helpers don&amp;#8217;t make use of the features available in RESTful Rails enabled apps.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Dan Kubb</dc:creator><pubDate>Thu, 19 Apr 2007 13:27:00 -0000</pubDate></item><item><title>Re: Jester 1.1: Asynchronous REST</title><link>http://giantrobots.disqus.com/jester_11_asynchronous_rest/#comment-14585580</link><description>&lt;p&gt;Eric, there was some talk &lt;a href="http://www.zerosum.org/devblog/?q=node/47" rel="nofollow"&gt;over here&lt;/a&gt; about how Rail&amp;#8217;s AutoComplete helper used an approach that doesn&amp;#8217;t really fit with the RESTful Rails way of doing things.&lt;/p&gt;&lt;br&gt;&lt;br&gt;&lt;p&gt;In that article&amp;#8217;s comments I mentioned I think a better approach would be to just use the standard #index action, and return XML using respond_to.  On the client side it could be parsed and used to create an AutoComplete field, just like how AutoComplete works now.&lt;/p&gt;&lt;br&gt;&lt;br&gt;&lt;p&gt;Taking it a step further, I could see a benefit of writing a plugin that can act as a stand-in replacement for normal Rails javascript helpers (like AutoComplete) but using Jester and RESTful Controllers.&lt;/p&gt;&lt;br&gt;&lt;br&gt;&lt;p&gt;My comment above was mainly to see if anyone&amp;#8217;s gone down this road or if there&amp;#8217;s any interest in this area.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Dan Kubb</dc:creator><pubDate>Thu, 19 Apr 2007 20:00:00 -0000</pubDate></item><item><title>Re: Jester 1.1: Asynchronous REST</title><link>http://giantrobots.disqus.com/jester_11_asynchronous_rest/#comment-14585586</link><description>&lt;p&gt;Eric, the main helpers that could be better done RESTfully are the ones for AutoCompleter and InPlaceEditor.  In the docs it says they&amp;#8217;ll be pulled out of the core into plugins before Rails 2.0 is released.&lt;/p&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;	&lt;p&gt;In AutoCompleter&amp;#8217;s case it would be better to do a GET to the #index action, retrieving the xml formatted data to merge into the autocompletion field.  For InPlaceEditor, it would be better to do a PUT to the #update action.&lt;/p&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;	&lt;p&gt;Actually, the worst part about these is that they&amp;#8217;re paired with other helpers that dynamically add actions to the controllers to handle their respective requests.  Nasty.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Dan Kubb</dc:creator><pubDate>Thu, 03 May 2007 01:53:00 -0000</pubDate></item><item><title>Re: The URL Police</title><link>http://giantrobots.disqus.com/the_url_police/#comment-14586740</link><description>&lt;p&gt;I like to use a DRY version of the precise approach.  I create my own submit_tag helper method in ApplicationHelper like so:&lt;/p&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;code&gt;def submit_tag(value, options = {})&lt;br&gt;  super value, options.merge :name =&amp;gt; nil&lt;br&gt;end&lt;/code&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;	&lt;p&gt;I do this with any Rails helper that I want to supply defaults to.  I sometimes even use this to raise exceptions when I forget to specify certain parameters, like :title for any form fields.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Dan Kubb</dc:creator><pubDate>Wed, 14 Nov 2007 16:42:00 -0000</pubDate></item><item><title>Re: To em, or to err.</title><link>http://giantrobots.disqus.com/to_em_or_to_err/#comment-14586956</link><description>&lt;p&gt;&lt;a href="http://haml.hamptoncatlin.com/docs/rdoc/classes/Sass.html" rel="nofollow"&gt;SASS&lt;/a&gt; has something built-in where you can specify the default sizes, and use math within the CSS-like syntax to calculate relative sizes of fonts and line heights.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Dan Kubb</dc:creator><pubDate>Tue, 29 Jan 2008 21:38:00 -0000</pubDate></item><item><title>Re: what, is it good for? absolutely nothing</title><link>http://giantrobots.disqus.com/what_is_it_good_for_absolutely_nothing/#comment-14587042</link><description>&lt;p&gt;This is a pretty nice idiom.  Its probably worth submitting as a patch to Rails, since I think it much cleaner than using == to test the format type.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Dan Kubb</dc:creator><pubDate>Fri, 22 Feb 2008 14:05:00 -0000</pubDate></item><item><title>Re: RESTful contact forms</title><link>http://giantrobots.disqus.com/restful_contact_forms_04/#comment-14587232</link><description>I don&amp;#8217;t have any huge improvements over what you&amp;#8217;ve done here, but you could always pass the form values into Notifier.deliver_contact_form using Hash#values_at:&lt;br&gt;&amp;lt;filter:code lang="ruby"&amp;gt;&lt;br&gt;Notifier.deliver_contact_form *params.values_at(:name, :email, :message, :referer)&lt;br&gt;&amp;lt;/filter&amp;gt;&lt;br&gt;&lt;br&gt;	&lt;p&gt;I&amp;#8217;m also not sure the &amp;#8220;and return&amp;#8221; in the action is necessary.  I suppose its an ok idiom to use when you need to return from the middle of the action, but when its the last statement in the action its unecessary.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Dan Kubb</dc:creator><pubDate>Fri, 04 Apr 2008 11:50:00 -0000</pubDate></item></channel></rss>