<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-30954145</atom:id><lastBuildDate>Wed, 11 Dec 2024 19:00:23 +0000</lastBuildDate><title>Progress vs. Perfection</title><description></description><link>http://progress-vs-perfection.blogspot.com/</link><managingEditor>noreply@blogger.com (Unknown)</managingEditor><generator>Blogger</generator><openSearch:totalResults>35</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-30954145.post-524085720148258163</guid><pubDate>Fri, 12 Dec 2008 19:30:00 +0000</pubDate><atom:updated>2009-01-14T11:40:15.377-08:00</atom:updated><title>TDD: I am finally getting it</title><description>My friend Mark and I have talked a lot in the past about doing more at unit testing.  That&#39;s something I&#39;ve really been focusing on lately and one of the things that has come out of it is that code written for unit tests is subtly different than code not.  This became crystal clear to me just a moment ago as I was writing this code:&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://pastie.org/322821&quot;&gt;http://pastie.org/322821&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The first way I wrote it was a somewhat untestable way of doing things: in order to test AllowPost my unit test had to know all about our configuration stuff and it just couldn&#39;t easily be tested without a bunch of dependencies.  Of course, my unit test framework doesn&#39;t know about those dependencies without making it jump through a whole bunch of hoops.  By re-writing it the second way, the method AllowPost was an atomic unit that could be tested without knowing about the other stuff.&lt;br /&gt;&lt;br /&gt;Of course, I want some tests that cover &quot;the other stuff&quot;, but that&#39;s at a higher level.  First, I have to get the lowest levels of tests working before the higher level tests will, otherwise it&#39;s all spaghetti.&lt;br /&gt;&lt;br /&gt;This may all be old news to you, but for me it really drove home the phrase &quot;test-driven development&quot;...in other words, the tests are actually shaping the code.  Suddenly, it makes so much sense why, in order for TDD to be effective, you have to write the tests first.  Otherwise, you may end up with code that isn&#39;t testable in terms of a unit test framework.</description><link>http://progress-vs-perfection.blogspot.com/2008/12/tdd-i-am-finally-getting-it.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-30954145.post-2974299624794855893</guid><pubDate>Fri, 09 May 2008 09:56:00 +0000</pubDate><atom:updated>2008-05-09T02:59:25.127-07:00</atom:updated><title>attachment_fu (with rmagick) on windows not working</title><description>man, i had a heck of a time getting attachment_fu (using rmagick) on windows working tonight.  let me just start with this: if you&#39;re having problems, just reboot.  it would have saved me an hour.&lt;br /&gt;&lt;br /&gt;i followed all the instructions and fixed all the hacks, yet for some reason thumbnails were not generating and the height and width was not being saved.  there are lots and lots of articles out there on these topics.  most of them discuss how the size isn&#39;t being saved, but in my case the size &lt;span style=&quot;font-style: italic;&quot;&gt;was&lt;/span&gt; being saved.&lt;br /&gt;&lt;br /&gt;how&#39;d fix it: i rebooted the machine and it worked.</description><link>http://progress-vs-perfection.blogspot.com/2008/05/attachmentfu-with-rmagick-on-windows.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-30954145.post-7898829975276361155</guid><pubDate>Mon, 18 Feb 2008 02:04:00 +0000</pubDate><atom:updated>2008-02-17T18:17:10.613-08:00</atom:updated><title>How To Upgrade to Rails 2.0 from 1.2.5</title><description>I had to upgrade my Rails app last night to 2.0.2 from 1.2.5.  This is a brief overview of what it took to make it happen.  I&#39;ll write some other posts soon with more details.  A little background: I&#39;m using InstantRails and the Aptana RadRails IDE on Windows XP SP2.&lt;br /&gt;&lt;br /&gt;Here&#39;s what I did:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Installed Instant Rails 2.0.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Checked out a working copy of my code from SVN&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Updated environments.rb: RAILS_GEM_VERSION = &#39;2.0.2&#39;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Fired it up: didn&#39;t work.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;I&#39;m using acts_as_tree and acts_as_list, so I needed to install those plugins.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Fired it up: didn&#39;t work.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;I&#39;m also using Comatose, and there was an error with the &quot;template_root&quot;.  Bottom line: after reading some message boards, etc. I removed and reinstalled the Comatose plugin and that fixed it.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Fired it up: didn&#39;t work.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Was getting this error:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;Status: 500 Internal Server Error&lt;br /&gt;  A secret is required to generate an integrity hash for cookie session data. Us&lt;br /&gt;e config.action_controller.session = { :session_key =&gt; &quot;_myapp_session&quot;, :secret&lt;br /&gt; =&gt; &quot;some secret phrase of at least 30 characters&quot; } in config/environment.rb&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Well, that message says it all, so I changed that.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Fired it up: was working.  Now, navigated my app...errors.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Had to change &#39;:dependent =&gt; true&#39; to &#39;:dependent =&gt; :destroy&#39;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Removed the line(s) config/environments/development.rb:12:  config.breakpoint_server = true&lt;br /&gt;from configuration since the setting has no effect anymore.&lt;br /&gt;  Instead, start `script/server` with the &quot;-u&quot; or &quot;--debugger&quot; option (or &quot;-h&quot;&lt;br /&gt;  to see all the options).  This wasn&#39;t causing an error, but while trying to figure out the dependent =&gt; :destroy thing, I read it on someone&#39;s blog, so I removed it.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Also, had to install the classic_pagination plugin.  (Really, every blog out there says I should upgrade to will_paginate, but my blog is about progress vs. perfection.  Old school pagination works for me for now, so I&#39;ll stick with it.)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Fired it up...everything running, but still some functionality isn&#39;t working.  (Gee...I wish I&#39;d writen *all* the unit tests.  Okay, let&#39;s debug.)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Opened RadRails, imported existing directory into a project.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Got this error: rad rails &quot;Cannot find gem for Rails ~&gt;2.0.2.0:&quot;...had to switch workspace because I installed the new Instant Rails and RadRails was still pointing at the old one.  (Not an issue if you overwrite, but I&#39;m running my concurrently.)&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Hmmm...the server runs through Aptana RadRails, but debugger is slow as heck...turns out that I updated ruby-debug-ide when I updated gems and that un-checked the checkbox for using the fast debugger in the IDE.  Also, had to install ruby-debug-base.  (I don&#39;t think this was required before, but once I installed it the debugger worked.)&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;Whew, well, I haven&#39;t found my bug yet, but that&#39;s how far I&#39;ve progressed.  Hopefully this will help the next guy out.</description><link>http://progress-vs-perfection.blogspot.com/2008/02/how-to-upgrade-to-rails-20-from-125.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-30954145.post-9102869006856571484</guid><pubDate>Mon, 31 Dec 2007 23:02:00 +0000</pubDate><atom:updated>2007-12-31T15:33:22.463-08:00</atom:updated><title>Rails vs. ASP.NET (Really, Ruby vs C#)</title><description>Where have I been...why the lack of posts: a) holidays, b) knee injury playing basketball (that required surgery to repair) has slowed me down, c) recently, I&#39;ve started to work on a project where ASP.NET using C# was the requirement.  &lt;br /&gt;&lt;br /&gt;So, I haven&#39;t been working in Rails for a few weeks and it&#39;s been a few years since I&#39;ve used ASP.NET or C#, so I&#39;ve had to jump back into it a little to refresh myself.&lt;br /&gt;&lt;br /&gt;Now, look, I&#39;m not trying to start a religious war here: ASP.NET and Rails each have their own benefits and drawbacks.  However, I would like to say this: for simple web sites Rails is so much &lt;span style=&quot;font-style:italic;&quot;&gt;easier&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;Here&#39;s a simple example: I&#39;ve got a URL stored in the database, such as http://www.mysite.com/foo/fee/foh.htm and I need to get the foh.htm (which isn&#39;t stored).  &lt;br /&gt;&lt;br /&gt;ASP.NET with C#&lt;br /&gt;&lt;code&gt;&lt;pre&gt;    public string FileName&lt;br /&gt;    {&lt;br /&gt;        get&lt;br /&gt;        {&lt;br /&gt;            char[] delim = { &#39;/&#39; };&lt;br /&gt;            string[] a = this.Url.Split(delim);&lt;br /&gt;            return a[a.Length - 1];&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;&lt;/code&gt;  &lt;br /&gt;Rails with Ruby&lt;br /&gt;&lt;code&gt;&lt;pre&gt;  def filename&lt;br /&gt;    self.url.split(&#39;/&#39;).last&lt;br /&gt;  end&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;I&#39;m sure I&#39;m not the first person to make this comparison.  I just felt compelled to speak out about the many moments during the day where it takes me several minutes longer to do something with ASP.NET and C# than Ruby and Rails.</description><link>http://progress-vs-perfection.blogspot.com/2007/12/rails-vs-aspnet-really-ruby-vs-c.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>6</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-30954145.post-8402606529254794752</guid><pubDate>Thu, 20 Dec 2007 17:53:00 +0000</pubDate><atom:updated>2007-12-20T10:01:38.259-08:00</atom:updated><title>How to Make Subversion via HTTP work with RailsMachine (and Capistrano)</title><description>Last night I setup my site on RailsMachine.  Overall, it was a very pleasant experience.  One bugaboo that I ran into:&lt;br /&gt;&lt;br /&gt;I have my Subversion repository setup using http, not svn+ssh.  The repository is hosted at Joyent and I don&#39;t recall why I set it up this way, but there must have been a reason.&lt;br /&gt;&lt;br /&gt;Anyhoo...so, I&#39;m plugging away with RailsMachine and using Capistrano for the first time and it&#39;s all pretty sweet, except for I can&#39;t seem to access my svn repository.  Cap would reach the point in the script where it made the HTTP request and I would see the HTTP authentication, but I had no way to type in my user/pass combo, and it would fail.&lt;br /&gt;&lt;br /&gt;Long story short: RailsMachine requires that you run Cap using a user called &quot;deploy&quot;, and those are the credentials that Cap passes via HTTP Authentication to the svn repository.  So, I was able to get it to work by simply creating a user for my svn repository called &quot;deploy&quot; with the same password as &quot;deploy&quot; on my RailsMachine server.  Everything works fine now!</description><link>http://progress-vs-perfection.blogspot.com/2007/12/how-to-make-subversion-via-http-work.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-30954145.post-40489445506493417</guid><pubDate>Tue, 11 Dec 2007 17:33:00 +0000</pubDate><atom:updated>2007-12-11T10:11:26.403-08:00</atom:updated><title>more on attachment_fu on windows</title><description>In my previous post about &lt;a href=&quot;http://progress-vs-perfection.blogspot.com/2007/11/attachmentfu-with-rmagick-on-windows.html&quot;&gt;attachment_fu (with rmagick) on windows&lt;/a&gt;, I did something sort of silly in the #create action of my controller: Windows required a little time to catch up because the file system loaded the file slower that attachemnt_fu needed it.  To solve that problem, I added &quot;sleep 5&quot; immediately before MyObject#save.&lt;br /&gt;&lt;br /&gt;The problem with that hack is every time I need to #save I have to remember to insert the &quot;sleep 5&quot; hack.  That&#39;s a mistake waiting to happen.  So, I moved the sleep to the model, like so:&lt;br /&gt;&lt;code&gt;&lt;pre&gt;&lt;br /&gt;  class MyObject &lt; ActiveRecord::Base&lt;br /&gt;    def before_save&lt;br /&gt;      sleep 5  ## &lt;&lt;-- pauses so Windows can catch up.  &lt;br /&gt;    end&lt;br /&gt;  end&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;It&#39;s much more logical that this code is part of the model because the delay is fundamentally a part saving the object, not a part of responding to an action.  &lt;br /&gt;&lt;br /&gt;This also address the notion of keeping your controllers skinny and your models fat.  Jamis Buck blogs very eloquently about this notion &lt;a href=&quot;http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model&quot;&gt;here&lt;/a&gt;.</description><link>http://progress-vs-perfection.blogspot.com/2007/12/more-on-attachmentfu-on-windows.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-30954145.post-1642765449920383029</guid><pubDate>Tue, 20 Nov 2007 06:42:00 +0000</pubDate><atom:updated>2007-11-19T23:43:49.595-08:00</atom:updated><title>attachment_fu (with rmagick) on windows</title><description>Today, I&#39;ve been working to get attachment_fu working with rmagick on Windows.  At first, it wasn&#39;t uploading the file properly and after much Googling implemented these changes to get it working.&lt;br /&gt;&lt;br /&gt;1.  I added a pause to my #create in order to allow Windows time to catch up.  In short, Ruby is moving faster than the Windows file system, and it was trying to create a record for a file that didn&#39;t exist yet.  Here&#39;s what I did:&lt;br /&gt;&lt;code&gt;&lt;pre&gt;  def create&lt;br /&gt;    @upload = Upload.new(params[:upload])&lt;br /&gt;    sleep 5  ## &lt;&lt;-- pauses so Windows can catch up.  Probably would be&lt;br /&gt;             ## smart to make this something like sleep 5 if OS == Windows&lt;br /&gt;             ## obviously, that&#39;s not the right syntax.&lt;br /&gt;    if @upload.save&lt;br /&gt;      flash[:notice] = &#39;Upload was successfully created.&#39;&lt;br /&gt;      redirect_to :action =&gt; &#39;list&#39;&lt;br /&gt;    else&lt;br /&gt;      render :action =&gt; &#39;new&#39;&lt;br /&gt;    end&lt;br /&gt;  end&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;I am fully aware that this is a hack, but it gets the job done.&lt;br /&gt;&lt;br /&gt;2.  I continued to get the error message &quot;Size is not included in the list&quot;.  Long story short, this is the error message attachment_fu returns when the file size exceeds the limit set in the model.  In addition, it provides this message if no file is provided at all which is a duplicate error because validates_as_attachment is already doing a validates_presence_of against the size.&lt;br /&gt;&lt;br /&gt;So, in order to create some better error messaging, and following the notions of how to hack a plugin from &lt;a href=&quot;http://errtheblog.com/post/19679&quot;&gt;this blog post&lt;/a&gt;, I created a new plugin called attachment_fu_hacks and in init.rb added this code:&lt;br /&gt;&lt;code&gt;&lt;pre&gt;klass = Numeric&lt;br /&gt;klass.class_eval do&lt;br /&gt;  def to_human&lt;br /&gt;    units = %w{B KB MB GB TB}&lt;br /&gt;    e = (Math.log(self)/Math.log(1024)).floor&lt;br /&gt;    s = &quot;%.1f&quot; % (to_f / 1024**e)&lt;br /&gt;    s.sub(/\.?0*$/, &#39; &#39; + units[e])&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;klass = Technoweenie::AttachmentFu::InstanceMethods&lt;br /&gt;klass.module_eval do&lt;br /&gt;  &lt;br /&gt;  # overrides attachment_fu.rb:342 b/c to provide better error messages&lt;br /&gt;  def attachment_attributes_valid?&lt;br /&gt;   &lt;br /&gt;    attr_name = :size&lt;br /&gt;    enum = attachment_options[attr_name]&lt;br /&gt;    val = send(attr_name)&lt;br /&gt;    if !enum.nil? &amp;&amp; !val.nil? &amp;&amp; !enum.include?(val)&lt;br /&gt;      err_msg = enum.end.to_human&lt;br /&gt;      errors.add attr_name, &quot;of file is too big (must be less than #{err_msg})&quot;&lt;br /&gt;    end&lt;br /&gt;    &lt;br /&gt;    attr_name = :content_type&lt;br /&gt;    enum = attachment_options[attr_name]&lt;br /&gt;    val = send(attr_name)&lt;br /&gt;    if !enum.nil? &amp;&amp; !val.nil? &amp;&amp; !enum.include?(val)&lt;br /&gt;      err_msg = enum.join(&#39;, &#39;).gsub(/image\//, &#39;.&#39;) unless enum.nil?&lt;br /&gt;      errors.add attr_name, &quot;is not supported (must be #{err_msg})&quot;      &lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;end  &lt;br /&gt;&lt;br /&gt;klass = Technoweenie::AttachmentFu::ClassMethods&lt;br /&gt;klass.module_eval do&lt;br /&gt;  # overrides attachment_fu.rb:106 b/c i don&#39;t think it&#39;s necessary &lt;br /&gt;  # to evaluate size or content_type if there is no file&lt;br /&gt;  def validates_as_attachment&lt;br /&gt;    validates_presence_of :filename&lt;br /&gt;    validate              :attachment_attributes_valid?&lt;br /&gt;  end  &lt;br /&gt;end&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;I recognize that there might be a more idiomatic Ruby way to write attachment_attributes_valid?, but I prefer this because it&#39;s very clear as to what&#39;s going on.</description><link>http://progress-vs-perfection.blogspot.com/2007/11/attachmentfu-with-rmagick-on-windows.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-30954145.post-4989555404240679236</guid><pubDate>Fri, 09 Nov 2007 00:42:00 +0000</pubDate><atom:updated>2007-11-08T16:52:18.693-08:00</atom:updated><title>Issue with has_many and Array.empty?</title><description>I&#39;ve posted a narrative of my issue on the &lt;a href=&quot;http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/ba40ce266ed53161/7f43de07f06dbdcb#7f43de07f06dbdcb&quot;&gt;Google Rails Group&lt;/a&gt;: &lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;pre&gt;&lt;br /&gt;/app/controllers/document_groups_controller.rb&lt;br /&gt;  def show&lt;br /&gt;    @document_group = DocumentGroup.find(params[:id])&lt;br /&gt;    @journal = Journal.find(params[:journal_id])&lt;br /&gt;    @document_group_templates = @document_group.document_templates&lt;br /&gt;    @logger = RAILS_DEFAULT_LOGGER&lt;br /&gt;    &lt;br /&gt;    #&lt;br /&gt;    # this is the money line: comment it out and @document_group_templates.empty?&lt;br /&gt;    # is true in the view.  leave it in, and it&#39;s false.  true is correct.&lt;br /&gt;    #&lt;br /&gt;    @logger.debug &quot;###### ---&gt;&quot; + @document_group_templates.inspect&lt;br /&gt;    #&lt;br /&gt;    # it turns out that this triggers the SQL to be run by Rails that acutally&lt;br /&gt;    # populates the @document_group_templates Array.&lt;br /&gt;    #&lt;br /&gt;&lt;br /&gt;    render :action =&gt; :show, :layout =&gt; &#39;ajax_div&#39;&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;/app/views/document_groups/show.rhtml&lt;br /&gt;#&lt;br /&gt;#@document_group_templates.empty? evaluates to true without the inspection above&lt;br /&gt;#&lt;br /&gt;&amp;lt;% if !@document_group_templates.empty? %&amp;gt;&lt;br /&gt;# &lt;br /&gt;# now, what&#39;s interesting is that if i change this to &lt;br /&gt;#&lt;br /&gt;#  if @document_group_templates.count &amp;gt; 0&lt;br /&gt;#&lt;br /&gt;# that also triggers the SQL to be run.  but, interestingly, #size does not &lt;br /&gt;# trigger the SQL.&lt;br /&gt;#&lt;br /&gt; &amp;lt;ul&amp;gt;&lt;br /&gt; &amp;lt;% &lt;br /&gt;  @document_group_templates.each do |child| &lt;br /&gt;            %&amp;gt;&amp;lt;li&amp;gt;&amp;lt;%= link_to child.name, :controller =&amp;gt; :template, :action =&amp;gt; :show, :id =&amp;gt; child.id %&amp;gt;&amp;lt;%&lt;br /&gt;  end&lt;br /&gt;  %&gt;&lt;br /&gt;  &amp;lt;/ul&amp;gt;&lt;br /&gt;&amp;lt;% end %&amp;gt;&lt;br /&gt;&lt;br /&gt;/app/models/document_group.rb&lt;br /&gt;class DocumentGroup &lt; ActiveRecord::Base&lt;br /&gt;  has_many :document_templates, :order =&gt; :document_group_position&lt;br /&gt;  acts_as_tree :counter_cache =&gt; true&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;/app/models/document_template.rb&lt;br /&gt;class DocumentTemplate &lt; ActiveRecord::Base&lt;br /&gt;  belongs_to :document_group, :counter_cache =&gt; true&lt;br /&gt;  acts_as_list :scope =&gt; :document_group, :column =&gt; :document_group_position&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;/code&gt;</description><link>http://progress-vs-perfection.blogspot.com/2007/11/issue-with-arrayempty.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-30954145.post-6420129065754230983</guid><pubDate>Mon, 05 Nov 2007 21:59:00 +0000</pubDate><atom:updated>2007-11-05T14:12:28.734-08:00</atom:updated><title>How to call render :partial properly</title><description>At some point, you may be going bananas because you&#39;re getting this error:&lt;br /&gt;&lt;code&gt;&lt;pre&gt;NoMethodError in DocumentController#new&lt;br /&gt;undefined method `include?&#39; for :new:Symbol&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;and the problem is that you&#39;re doing this somewhere:&lt;br /&gt;&lt;code&gt;&lt;pre&gt;render :partial =&gt; :new&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;instead of this:&lt;br /&gt;&lt;code&gt;&lt;pre&gt;render :partial =&gt; &#39;new&#39;&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;This error is spawned by the method partial_pieces in /ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/partials.rb:90 which is trying to figure out if the partial you&#39;re calling is in the directory of the current controller, or some other directory.  Here&#39;s that code:&lt;br /&gt;&lt;code&gt;&lt;pre&gt;89      def partial_pieces(partial_path)&lt;br /&gt;90        if partial_path.include?(&#39;/&#39;)&lt;br /&gt;91          return File.dirname(partial_path), File.basename(partial_path)&lt;br /&gt;92        else&lt;br /&gt;93          return controller.class.controller_path, partial_path&lt;br /&gt;94        end&lt;br /&gt;95      end&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;The error comes from line 90.  Seems like if this were inserted at line 89.5, then this problem could be handled more gracefully&lt;br /&gt;&lt;code&gt;&lt;pre&gt;partial_path = partial_path.to_s if partial_path.is_a? Symbol&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;given the fuzzyness of symbols and strings, it would seem to make sense to me.</description><link>http://progress-vs-perfection.blogspot.com/2007/11/how-to-call-render-partial-properly.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-30954145.post-8973844359430203280</guid><pubDate>Tue, 30 Oct 2007 00:45:00 +0000</pubDate><atom:updated>2007-10-29T17:50:28.201-07:00</atom:updated><title>How to Avoid and Infinite Loop with before_save and after_save</title><description>I have an entity that looks something like this:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;journal&lt;br /&gt;  author_first_name&lt;br /&gt;  author_last_name&lt;br /&gt;  journal_name&lt;br /&gt;  journal_email_address&lt;/pre&gt;&lt;br /&gt;where&lt;br /&gt;&lt;pre&gt;journal_name = author_first_name + &#39; &#39; + author_last_name&lt;br /&gt;journal_email_address = journal_name + &#39;-&#39; id&lt;/pre&gt;&lt;br /&gt;I had journal_name and journal_email_address implemented as attributes on the Journal model, but the time came along where, for various reasons, it has become valuable to also store that information in the database. So, what I thought I’d do, in app/models/journal.rb:&lt;br /&gt;&lt;code&gt;&lt;pre&gt;def make_journal_name&lt;br /&gt;  self.journal_name = self.author_first_name + &#39; &#39; + self.author_last_name&lt;br /&gt;end  &lt;br /&gt;&lt;br /&gt;def make_inbound_email&lt;br /&gt;  self.inbound_email = self.journal_name.gsub(/[^a-zA-Z0-9]/, &#39;&#39;) + &#39;-&#39; + self.id.to_s&lt;br /&gt;end&lt;br /&gt;def before_save&lt;br /&gt;  make_journal_name&lt;br /&gt;  make_inbound_email&lt;br /&gt;end&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;which works fine in the case of an update of an existing record. However, it does not work in the case of a creation of a new record because before saving self.id does not exist. The result was my e-mail addresses are looking like “SallyJones-” as opposed to “SallyJones-64”.&lt;br /&gt;&lt;br /&gt;Okay, I thought, “since I need an ID to work with I’ll move this to after_save,” like so:&lt;br /&gt;&lt;code&gt;&lt;pre&gt;def after_save&lt;br /&gt;  make_journal_name&lt;br /&gt;  make_inbound_email&lt;br /&gt;  self.save&lt;br /&gt;end&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;but that creates an infinite loop.&lt;br /&gt;&lt;br /&gt;The solution to this problem is to use an undocumented method: update_without_callbacks.&lt;br /&gt;&lt;code&gt;&lt;pre&gt;def after_save&lt;br /&gt;  make_journal_name&lt;br /&gt;  make_inbound_email&lt;br /&gt;  self.update_without_callbacks&lt;br /&gt;end&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;update_without_callbacks is an instance method on ActiveRecord::Base, but for some reason it’s undocumented. In fact, it explicitly has :nodoc set in the source, although I can’t figure out why. To me, it seems that having more documented is better than having less.</description><link>http://progress-vs-perfection.blogspot.com/2007/10/how-to-avoid-and-infinite-loop-with.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-30954145.post-3460136318470347554</guid><pubDate>Thu, 25 Oct 2007 00:05:00 +0000</pubDate><atom:updated>2007-10-24T17:33:01.185-07:00</atom:updated><title>The Rails Way</title><description>A big part of using Rails is understanding that if you conform to &quot;The Rails Way&quot; things are much easier.  Of course, The Rails Way might not work for your project, and in that case, Rails might not be the right framework choice.  But, you have to learn The Rails Way in order to know.&lt;br /&gt;&lt;br /&gt;I can&#39;t claim to explain The Rails Way completely, but I&#39;ve been helping a new (to Rails) developer on my team get up and running, so I&#39;ve been having to coach him to see  The Rails Way.&lt;br /&gt;&lt;br /&gt;I started by talking about &quot;entities&quot;.  An entity is a thing like a &quot;widget&quot;...some object in our application domain that we need to represent.  By convention, the names of the database table, unit tests, models, controllers, views, layouts and helpers must always coordinated in Rails to the name of the entity.  So, with our &quot;widget&quot; entity, this is how they should be:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;DB Table: widgets&lt;br /&gt;&lt;li&gt;Model: app/models/widget.rb&lt;br /&gt;&lt;li&gt;Controller: app/controllers/widgets_controller.rb&lt;br /&gt;&lt;li&gt;View: app/views/widget/...&lt;br /&gt;&lt;li&gt;Layout: app/views/layouts/widgets.rhtml&lt;br /&gt;&lt;li&gt;Helper: app/helpers/widgets_helper.rb&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;The beautiful thing about Rails is that by using generators, this gets managed for you.  Here’s the approach I always take when creating an entity.  This can be done through an IDE (such as RadRails, which is what I use) or on the command line...I’ll use the command line here:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;&lt;font face=&quot;courier new&quot;&gt;cd path/to/rails/app&lt;/font&gt;&lt;br /&gt;&lt;li&gt;&lt;font face=&quot;courier new&quot;&gt;ruby ./script/generate model Widget&lt;/font&gt; which will generate your model file and your migration file with the proper table name.&lt;br /&gt;&lt;li&gt;Open up the migration, add the appropriate columns and save.&lt;br /&gt;&lt;li&gt;&lt;font face=&quot;courier new&quot;&gt;rake db:migrate&lt;/font&gt; to apply your migration to the DB.&lt;br /&gt;&lt;li&gt;&lt;font face=&quot;courier new&quot;&gt;ruby ./script/generate scaffold Widget&lt;/font&gt; which will create your controller, views, layout and helper.&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;Generators create a starting point to start editing, and it also gets all the file names correct.  Let’s talk about the editing that needs to happen.  Personally, I always do my editing in this order:&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;Migration&lt;br /&gt;&lt;li&gt;Model&lt;br /&gt;&lt;li&gt;Controllers&lt;br /&gt;&lt;li&gt;Views&lt;br /&gt;&lt;li&gt;Layouts&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;This makes the most sense to me because I’m starting with the raw data, and working my way forward to what the user sees on the web page.&lt;br /&gt;&lt;br /&gt;A little background on controllers (a good article to read is this: http://www.softiesonrails.com/search?q=rest+101): Your standard CRUD controller has 8 actions:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Create (Create): /widgets/create&lt;br /&gt;&lt;li&gt;Show (Read): /widgets/show/:id&lt;br /&gt;&lt;li&gt;Update (Update): /widgets/update/:id&lt;br /&gt;&lt;li&gt;Destroy (Delete): /widgets/destroy/:id&lt;br /&gt;&lt;li&gt;New (precursor to create): /widgets/new&lt;br /&gt;&lt;li&gt;Edit (precursor to update): /widgets/edit/:id&lt;br /&gt;&lt;li&gt;List (lists all entities): /widgets/list&lt;br /&gt;&lt;li&gt;Index (the default action): /widgets&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;When, you generate your scaffold, it’s going to automatically generate the 8 actions above.  When designing entities if you have methods that don&#39;t fit within one of those actions then it&#39;s typically an indication that your entity model could our should be designed differently.&lt;br /&gt;&lt;br /&gt;(A great example of how it&#39;s all about entity design is the login and logout actions for a User.  I was thinking the other day about where the login and logout methods belong because they make sense on a User, but they aren&#39;t one of the above eight actions.  Of course, I was thinking about it all wrong: login and logout are really the Create and Destroy methods on the Session entity, and Session entities belong to a User.)&lt;br /&gt;&lt;br /&gt;Finally, a note in regard to the relationships between views, controllers and models in the context of validation.  The typical user pattern in relation to creating an entity is:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;User visits &lt;font face=&quot;courier new&quot;&gt;/widgets/new&lt;/font&gt; page&lt;br /&gt;&lt;li&gt;Enters data, click submit.&lt;br /&gt;&lt;li&gt;&lt;font face=&quot;courier new&quot;&gt;/widgets/new&lt;/font&gt; POSTs to Widgets#create&lt;br /&gt;&lt;li&gt;Widgets#create puts the data in the DB, then (if you look at the scaffold generated controller)&lt;ul&gt;&lt;br /&gt;&lt;li&gt;If success, calls &lt;font face=&quot;courier new&quot;&gt;redirect_to&lt;/font&gt;&lt;br /&gt;&lt;li&gt;If fails, calls &lt;font face=&quot;courier new&quot;&gt;render :action =&gt; :new&lt;/font&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;br /&gt;Why in one case does it redirect, and the other does it render?  It all has to do with a little method call that should appear in your new widgets view, i.e. &lt;font face=&quot;courier new&quot;&gt;/widgets/new&lt;/font&gt;:&lt;br /&gt;&lt;code&gt;&lt;pre&gt;&lt;%= error_messages_for &#39;widget&#39; %&gt;&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;See, a model has the capability to validate it’s attributes (e.g. lookup validates_presence_of in the Rails docs for examples of these capabilities).  When you call Object#save the validation routines are executed and if the model doesn’t validate (i.e. Object#save returns false) we render the new action again.  &lt;font face=&quot;courier new&quot;&gt;error_messages_for&lt;/font&gt; looks up the failures and automagically renders error messaging.  &lt;br /&gt;&lt;br /&gt;The beauty of generators is that &lt;font face=&quot;courier new&quot;&gt;script/generate scaffold Widget&lt;/font&gt; sets all of this up for you.</description><link>http://progress-vs-perfection.blogspot.com/2007/10/rails-way.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-30954145.post-4522395494461637006</guid><pubDate>Thu, 18 Oct 2007 16:29:00 +0000</pubDate><atom:updated>2007-10-18T09:34:09.282-07:00</atom:updated><title>The Problem with Rails Plugins</title><description>The other day Mark asked if I was using active_scaffold.  The answer is that I have a perfect use for it, and I installed it, and it works perfectly for what I need it for.  However, it also overrides some core Rails functions, and when I execute functionality in my portion of the app the active_scaffold version of those functions are throwing exceptions.  For example:&lt;br /&gt;&lt;code&gt;&lt;pre&gt;class ActionController::Routing::RouteSet &lt;br /&gt;  def generate_with_nil_id_awareness(*args) &lt;br /&gt;    args[0].delete(:id) if args[0][:id].nil? &lt;br /&gt;    generate_without_nil_id_awareness(*args) &lt;br /&gt;  end &lt;br /&gt;  alias_method_chain :generate, :nil_id_awareness &lt;br /&gt;end&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;Now, to me, ActionController::Routing::RouteSet seems like a pretty core function in Rails.  Of course, it may be the case that I’ve done something wrong and their updated version is catching that error.  (You can read more on that here: http://groups.google.com/group/activescaffold/browse_thread/thread/1c4e2f30e8b00ac6/309665c0a85d65c8).&lt;br /&gt;&lt;br /&gt;However, my thinking is that I don’t need some plugin f’ing with my app.  In fact, this points to a major issue with plugins…they’re not these self-contained units, i.e. components...but, rather, they are mixed in with the core Rails framework and our apps.  This means we must think very carefully about which plugins we’ll use because, effectively, we need to know them as well as we know our own code.  In other words, they are not black boxes...they are just code we import into our app that somebody else wrote (and is kind enough to share).  For example, active_scaffold installs 138 files, and who knows how many kLOCs of code, and who knows what funky stuff they’ve done.&lt;br /&gt;&lt;br /&gt;So, long story short, I’m not using active_scaffold because I don’t trust that there isn&#39;t come code in there that&#39;s gonna mess up my app, and it&#39;s too much code for me to review and become familiar with.  Any ideas on an alternative?  &lt;br /&gt;&lt;br /&gt;I’ve looked at Streamlined, Hobo Scaffolding Extensions.  According to the docs, Streamlined doesn’t do nested records editing which I require, Scaffolding Extensions handles nested record editing, but isn&#39;t the best UX, and Hobo has the same problem as Radiant CMS...I have to put my app into theirs, not their app into mine.  (However, both Radiant and Hobo seem like nice platforms for the right project, just not the one I&#39;m currently working on.)</description><link>http://progress-vs-perfection.blogspot.com/2007/10/problem-with-rails-plugins.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>4</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-30954145.post-6944301898337001410</guid><pubDate>Fri, 12 Oct 2007 17:19:00 +0000</pubDate><atom:updated>2007-10-12T10:21:33.079-07:00</atom:updated><title>What does &quot;idiomatic Ruby&quot; mean?</title><description>From a chat with &lt;a href=&quot;http://www.avogen.com&quot;&gt;Mark&lt;/a&gt; today, in regard to reading a post where I used the word &quot;idiomatic&quot;:&lt;br /&gt;&lt;code&gt;&lt;pre&gt;(10:10:42) Mark: idiomatic, what a word&lt;br /&gt;(10:11:12) Scott Porad: yes, i don&#39;t even know what it means...but people &lt;br /&gt;say it when they mean, &quot;there&#39;s a more clever way to write this in ruby&quot;.&lt;br /&gt;(10:11:26) Mark: Peculiar to or characteristic of a given language.&lt;br /&gt;(10:12:05) Mark: nice, one of the descriptions of idiomatic, uses idiomatic &lt;br /&gt;to describe it: Characterized by proficient use of idiomatic expressions&lt;/pre&gt;&lt;/code&gt;</description><link>http://progress-vs-perfection.blogspot.com/2007/10/what-does-idiomatic-ruby-mean.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-30954145.post-7732724323712820333</guid><pubDate>Thu, 11 Oct 2007 23:45:00 +0000</pubDate><atom:updated>2007-10-11T16:59:54.905-07:00</atom:updated><title>Acts As Authenticated and Reset Password</title><description>Using Acts as Authenticated, imagine this use case:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;User forgets password...has reset code sent to their e-mail.&lt;br /&gt;&lt;li&gt;User receives e-mail, clicks link to reset password.&lt;br /&gt;&lt;li&gt;User arrives on reset password page and thinks, &quot;hmmm...I think I&#39;ll go visit the homepage instead&quot;.&lt;br /&gt;&lt;li&gt;User types http://www.yoursite.com/ in their browser (or clicks a link the header, or whatever).&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;What happens is that when the user clicks the link in the email it takes them to /account/reset_password which looks up their account by the reset code on the link (which was sent in the e-mail) &lt;span style=&quot;font-weight:bold;&quot;&gt;&lt;span style=&quot;font-style:italic;&quot;&gt;and it logs them in&lt;/span&gt;&lt;/span&gt;.  So, when they decide, &quot;hmmm...I think I&#39;ll go visit the homepage instead,&quot; the user is now logged in, but has not reset their password.  &lt;br /&gt;&lt;br /&gt;To me, that seems to present a problem.  So, I added a before_filter to my ApplicationController that verifies that all logged in users must have a nil password reset code otherwise they are redirected to /account/change_password.  (The password reset code isn&#39;t cleared until after the user has successfully changed their password.)&lt;br /&gt;&lt;br /&gt;In the ApplicationController I added:&lt;br /&gt;&lt;code&gt;&lt;pre&gt;before_filter :ensure_password_reset&lt;/pre&gt;&lt;/code&gt;and&lt;br /&gt;&lt;code&gt;&lt;pre&gt;module AuthenticatedSystem&lt;br /&gt;  def ensure_password_reset&lt;br /&gt;    redirect_to :controller =&gt; :account, :action =&gt; :change_password unless reset_password_has_been_changed&lt;br /&gt;  end&lt;br /&gt;  &lt;br /&gt;  def reset_password_has_been_changed&lt;br /&gt;    if logged_in?&lt;br /&gt;      if current_user.password_reset_code.nil?&lt;br /&gt;        return true&lt;br /&gt;      else&lt;br /&gt;        return false&lt;br /&gt;      end&lt;br /&gt;    else&lt;br /&gt;      true&lt;br /&gt;    end&lt;br /&gt;  end  &lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;I&#39;m certain that there is a more idiomatic Ruby way to write reset_password_has_been_changed, but I couldn&#39;t think of it.</description><link>http://progress-vs-perfection.blogspot.com/2007/10/acts-as-authenticated-and-reset.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-30954145.post-6867011779483389925</guid><pubDate>Wed, 10 Oct 2007 17:08:00 +0000</pubDate><atom:updated>2007-10-10T16:18:27.356-07:00</atom:updated><title>Fixing a Blank Password Bug in Acts As Authenticated</title><description>I came across a bug in Acts As Authenticated when users tried to change their passwords.  If they submitted the form with nothing in the new or confirm new password text field, then no error was thrown, but the password wasn&#39;t changed either.&lt;br /&gt;&lt;br /&gt;The problem was in the :if clause on the validates_presence_of validation, password_required?.  It was causing the validation not to occur.&lt;br /&gt;&lt;code&gt;&lt;pre&gt;    def password_required?&lt;br /&gt;      crypted_password.blank? || !password.blank?&lt;br /&gt;    end&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;This code is saying that a password is required in two situations:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;when the crypted_password is blank -- that situation happens when creating a new user, &lt;span style=&quot;font-weight:bold;&quot;&gt;OR&lt;/span&gt; &lt;br /&gt;&lt;li&gt;when the class instance variable &#39;password&#39; is not blank -- this can only happen when the variable has been accessed, such as when attempting to update a password.&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;The bug is in the test for &lt;font face=&quot;courier&quot;&gt;!password.blank?&lt;/font&gt; because it&#39;s assuming that the user will enter something as a new password.  To resolve that, I changed the code to this:&lt;br /&gt;&lt;code&gt;&lt;pre&gt;    def password_required?&lt;br /&gt;      crypted_password.blank? || !password.nil?&lt;br /&gt;    end&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;and now the validation is called (and fails) properly.  More about this issue can be found in the last few posts on &lt;a href=&quot;http://technoweenie.stikipad.com/plugins/show/Change+Password&quot;&gt;this page&lt;/a&gt;.</description><link>http://progress-vs-perfection.blogspot.com/2007/10/fixing-blank-password-bug-in-acts-as.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-30954145.post-6919608868151962053</guid><pubDate>Wed, 10 Oct 2007 16:59:00 +0000</pubDate><atom:updated>2007-10-10T10:08:20.263-07:00</atom:updated><title>How To Make the Debugger Work with RadRails</title><description>I&#39;ve finally got the debugger working with Aptana&#39;s RadRails.&lt;br /&gt;&lt;br /&gt;I&#39;ve had the debugger working for awhile, but I was experiencing a problem where the current line, i.e. the current execution line, wasn&#39;t being highlighted.  Actually, the source file of the current line wasn&#39;t being even opened.&lt;br /&gt;&lt;br /&gt;After trolling around various messages boards, etc., I learned that the bug has been fixed in the latest beta version of RadRails.  Here’s a post on how to do that: http://www.aptana.com/forums/viewtopic.php?t=2939&lt;br /&gt;&lt;br /&gt;Personally, I had to manually add the update site in order to get it to work, although you might not have that experience.  Of course, it took me awhile to figure out how to do this...here you go:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Go to Help &gt; Software Updates &gt; Find and Install&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Select &quot;Search for new features to install&quot; and click &quot;Next&quot;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Click the button on the right for &quot;New Remote Site&quot;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Enter:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Name: RadRails Beta&lt;/li&gt;&lt;br /&gt;&lt;li&gt;URL: http://update.aptana.com/update/rails/beta/3.2/site.xml&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;li&gt;Click &#39;OK&#39;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Check the box next to &quot;RadRails Beta&quot;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Click the &quot;Finish&quot; button.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;Now the update should download and install.</description><link>http://progress-vs-perfection.blogspot.com/2007/10/how-to-make-debugger-work-with-radrails.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-30954145.post-8201178770184169455</guid><pubDate>Thu, 04 Oct 2007 08:59:00 +0000</pubDate><atom:updated>2007-10-04T02:20:03.322-07:00</atom:updated><title>Where to put/store/save/keep your modules and files containing modules?</title><description>To a Rails newbie, sometimes the simplest things are hard to figure out.  Here&#39;s what you need to know:&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;strong&gt;When you create a module, you save it to your lib/ directory.&lt;/strong&gt;&lt;/blockquote&gt;&lt;br /&gt;All the modules in the lib/ directory are auto-loaded by Rails.  That is, Rails does something like this:&lt;br /&gt;&lt;blockquote&gt;&lt;code&gt;&lt;pre&gt;for file in lib/&lt;br /&gt;   require file&lt;br /&gt;end&lt;/pre&gt;&lt;/code&gt;&lt;/blockquote&gt;Also, I think there is some magic to this, but I&#39;m not 100% sure.  If you have a module called MiscUtils then your file needs to be named misc_utils.rb in order for Rails to auto-load it.&lt;br /&gt;&lt;br /&gt;Additionally, Ruby does this super-sweet thing where you can re-open any class or module and add to it at any time.  In other words, you can declare a class or module in two locations, and Ruby will merge them together and treat them as one class.  My experience has been that when you do this, then you need to explicitly require the files even if they&#39;re in the lib directory.</description><link>http://progress-vs-perfection.blogspot.com/2007/10/where-to-putstoresavekeep-your-modules.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-30954145.post-5411765216448960404</guid><pubDate>Wed, 03 Oct 2007 18:36:00 +0000</pubDate><atom:updated>2007-10-03T11:58:02.934-07:00</atom:updated><title>What is that hyphen right before the closing of an ERb block?</title><description>Periodically, I see some ERb code in a view like this:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;&lt;% form_tag &#39;/posts&#39; do -%&gt;     &lt;/code&gt;&lt;br /&gt;    &lt;%= submit_tag &#39;Save&#39; %&gt;&lt;br /&gt;&lt;% end -%&gt;&lt;/pre&gt;&lt;br /&gt;In fact, that code was culled right from the Rails docs at for &lt;a href=&quot;http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#M000601&quot;&gt;form_tag&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;As you can see, in those two ERb tags, there is this syntax at close of the tag:&lt;br /&gt;&lt;code&gt;&lt;/code&gt;&lt;blockquote&gt;-%&amp;gt;&lt;/blockquote&gt;Today I was wondering what the hyphen (-) was for before the percentage symbol (%).  It turns out that the hyphen means that when the HTML output is generated there is no line return after the close of the ERb tag.&lt;br /&gt;&lt;br /&gt;For example, the ERb code above produces this HTML:&lt;br /&gt;&lt;code&gt;&lt;/code&gt;&lt;pre&gt;&amp;lt;form action=&quot;/posts&quot; method=&quot;post&quot;&amp;gt;    &amp;lt;div&gt;&amp;lt;input name=&quot;commit&quot; type=&quot;submit&quot; value=&quot;Save&quot; /&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&amp;lt;/form&amp;gt;&lt;/pre&gt;&lt;br /&gt;whereas this ERb code:&lt;br /&gt;&lt;code&gt;&lt;/code&gt;&lt;pre&gt;&lt;% form_tag &#39;/posts&#39; do %&gt;    &lt;br /&gt;    &lt;%= submit_tag &#39;Save&#39; %&gt;&lt;br /&gt;&lt;% end %&gt;&lt;/pre&gt;&lt;br /&gt;produces this HTML:&lt;br /&gt;&lt;code&gt;&lt;/code&gt;&lt;pre&gt;&amp;lt;form action=&quot;/posts&quot; method=&quot;post&quot;&amp;gt;&lt;br /&gt;    &amp;lt;div&amp;gt;&amp;lt;input name=&quot;commit&quot; type=&quot;submit&quot; value=&quot;Save&quot; /&amp;gt;&amp;lt;/div&gt;&lt;br /&gt;&amp;lt;/form&amp;gt;&lt;/pre&gt;</description><link>http://progress-vs-perfection.blogspot.com/2007/10/what-is-that-hyphen-right-before.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-30954145.post-4999220631227498354</guid><pubDate>Tue, 02 Oct 2007 03:53:00 +0000</pubDate><atom:updated>2007-10-01T21:05:26.256-07:00</atom:updated><title>How Mixins, Include and Extend Work</title><description>I was a little puzzled tonight by this chunk of code that I found in the acts_as_authenticated plug-in module:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;pre&gt;    def self.included(base)&lt;br /&gt;      base.send :helper_method, :current_user, :logged_in?&lt;br /&gt;    end&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;It comes down to some Ruby magic: when a module is included by a class the self.included method on the module is called.  Likewise, when a class extends a module the self.extended method is called.&lt;br /&gt;&lt;br /&gt;&quot;base&quot; is the class that includes/extends the module.  &quot;send&quot; is calling the method &quot;:helper_method&quot; and passing &quot;:current_user&quot; and &quot;:logged_in?&quot; as parameters.&lt;br /&gt;&lt;br /&gt;Special thanks to &lt;a href=&quot;http://www.juixe.com/techknow/index.php/2006/06/15/mixins-in-ruby/&quot;&gt;Juixe&lt;/a&gt; for an excellent article that helped me figure this out.</description><link>http://progress-vs-perfection.blogspot.com/2007/10/how-mixins-include-and-extend-work.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-30954145.post-7952152000874830161</guid><pubDate>Sat, 29 Sep 2007 00:43:00 +0000</pubDate><atom:updated>2007-09-28T17:49:45.905-07:00</atom:updated><title>DRY Migrations (aka reverting or undoing earlier migrations)</title><description>I have a case where I made some database changes in migration 001 and now I want to undo them in migration 005.  This is different that actually rolling back to version 001 (i.e. rake db:migrate version=1)...I actually want to undo or revert what I did in 001.  The obvious thing to do would be to simply have 005 do the opposite of 001, but that isn&#39;t very DRY.  &lt;br /&gt;&lt;br /&gt;Using a simple example, let&#39;s say my migrations were:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;001_create_books.rb&lt;br /&gt;&lt;li&gt;002_create_libraries.rb&lt;br /&gt;&lt;li&gt;003_create_librarians.rb&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;and now my library is going electronic, so I do this:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;004_create_e_books.rb&lt;br /&gt;&lt;li&gt;005_destroy_books.rb&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;In 005 I want to do the exact opposite of 001, so I did this:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;pre&gt;class DestroyBooks &lt; ActiveRecord::Migration&lt;br /&gt;  def self.up&lt;br /&gt;    CreateBooks::migrate(:down)&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  def self.down&lt;br /&gt;    CreateBooks::migrate(:up)&lt;br /&gt;  end&lt;br /&gt;end&lt;/pre&gt;&lt;/code&gt;</description><link>http://progress-vs-perfection.blogspot.com/2007/09/dry-migrations-aka-reverting-or-undoing.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-30954145.post-3340953658962184442</guid><pubDate>Thu, 27 Sep 2007 20:39:00 +0000</pubDate><atom:updated>2007-09-28T17:55:02.878-07:00</atom:updated><title>Custom Configurations and App Specific Settings</title><description>&lt;blockquote&gt;&lt;br /&gt;One not immediately obvious Ruby on Rails configuration issue I came across is how to structure application-specific config parameters, and in particular, how to make them configurable/overridable across different environments (dev, test, production). This has been solved repeatedly in different ways by the Rails community and there&#39;s info scattered around but assimilating it took a while, &lt;a href=&quot;http://lemurware.blogspot.com/2006/08/ruby-on-rails-configuration-and.html&quot;&gt;here&#39;s what I&#39;ve settled on&lt;/a&gt; for now.&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;I couldn&#39;t have said it better myself.  I&#39;ve now spent 4 hours researching the best way to do this...this is a basic feature of a web app, you&#39;d think there would be a conventional way to create ..whatever you want to call them: custom configurations, application specific settings, application configs...in Rails.&lt;br /&gt;&lt;br /&gt;At present, I&#39;ve found four solutions...the one suggested by the above blogger, and these three others:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;http://www.taknado.com/2007/7/25/custom-configuration-info-in-rails&lt;br /&gt;&lt;li&gt;http://jarmark.org/projects/app-config/&lt;br /&gt;&lt;li&gt;Use after_initialize method on the Rails::Configuration class.  (Note: this is only semi-well documented...it&#39;s documented, but not included at http://api.rubyonrails.org.  I found it here: http://edgedocs.planetargon.org/classes/Rails/Configuration.html#M002860)&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;In addition, I found these blog posts useful:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;http://toolmantim.com/article/2006/12/27/environments_and_the_rails_initialisation_process&lt;br /&gt;&lt;li&gt;http://glu.ttono.us/articles/2006/05/22/guide-environments-in-rails-1-1&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;I haven&#39;t decided how I&#39;m going to do this yet, but I hope you find this helpful.&lt;br /&gt;&lt;br /&gt;UPDATE: I was exchanging e-mail from Jeff at &lt;a href=&quot;http://www.softiesonrails.com&quot;&gt;softiesonrails.com&lt;/a&gt; who suggested this solution:&lt;br /&gt;&lt;blockquote&gt;What I usually do is add it to the bottom of environment.rb.  If I have RAILS_ENV-dependent data (like development mode vs. production mode), then just put the relevant Ruby code at the bottom of environments/development.rb, for example:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;pre&gt;    module MyConstants&lt;br /&gt;      ALLOWED_NAMES = [&#39;jeff&#39;, &#39;cookie monster&#39;]&lt;br /&gt;      IP_ALLOWED = &#39;1.2.3.4&#39;&lt;br /&gt;    end&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;and then you can access them anywhere in your Rails code as MyConstants::ALLOWED_NAMES, etc. &lt;br /&gt;&lt;br /&gt;If you prefer to move it to a file, you&#39;d create a file named my_constants.rb in the /lib folder, and then explicitly require it from environment.rb:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;pre&gt;    require &#39;my_constants&#39;&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;&lt;/blockquote&gt;</description><link>http://progress-vs-perfection.blogspot.com/2007/09/custom-configurations-and-app-specific.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-30954145.post-1209669765160047708</guid><pubDate>Wed, 19 Sep 2007 00:31:00 +0000</pubDate><atom:updated>2007-09-18T17:52:43.959-07:00</atom:updated><title>Reverting Migrations (self.drop) Issue</title><description>I created an ran a migration today.  Here is how my database looked to begin:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;mysql&gt; show tables;&lt;br /&gt;+--------------------------------------+&lt;br /&gt;| Tables_in_books_development          |&lt;br /&gt;+--------------------------------------+&lt;br /&gt;| journals                             |&lt;br /&gt;| schema_info                          |&lt;br /&gt;+--------------------------------------+&lt;br /&gt;2 rows in set (0.00 sec)&lt;br /&gt;&lt;br /&gt;mysql&gt; select * from schema_info;&lt;br /&gt;+---------+&lt;br /&gt;| version |&lt;br /&gt;+---------+&lt;br /&gt;|      19 |&lt;br /&gt;+---------+&lt;br /&gt;1 row in set (0.00 sec)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Then, I ran this migration:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;class CreateThemes &lt; ActiveRecord::Migration&lt;br /&gt;  def self.up&lt;br /&gt;    create_table :themes do |t|&lt;br /&gt;      t.column :name, :string&lt;br /&gt;      t.column :stylesheet_path, :string&lt;br /&gt;      t.column :thumbnail_path, :string&lt;br /&gt;      t.column :journals_count, :integer, :default =&gt; 0&lt;br /&gt;    end&lt;br /&gt;    #add_column :journals, :theme_id, :integer&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  def self.down&lt;br /&gt;    drop_table :themes&lt;br /&gt;    remove_column :journals, :theme_id&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Notice how I have the add_column method commented out.  Running Rake yields this:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;C:\rails_apps\books&gt;rake db:migrate&lt;br /&gt;(in C:/rails_apps/books)&lt;br /&gt;== CreateThemes: migrating ====================================================&lt;br /&gt;-- create_table(:themes)&lt;br /&gt;   -&gt; 0.1200s&lt;br /&gt;== CreateThemes: migrated (0.1200s) ===========================================&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;As you can see, the column is not added to the journals table.  Here&#39;s what my database looks like now:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;mysql&gt; show tables;&lt;br /&gt;+--------------------------------------+&lt;br /&gt;| Tables_in_books_development          |&lt;br /&gt;+--------------------------------------+&lt;br /&gt;| journals                             |&lt;br /&gt;| schema_info                          |&lt;br /&gt;| themes                               |&lt;br /&gt;+--------------------------------------+&lt;br /&gt;3 rows in set (0.00 sec)&lt;br /&gt;&lt;br /&gt;mysql&gt; select * from schema_info;&lt;br /&gt;+---------+&lt;br /&gt;| version |&lt;br /&gt;+---------+&lt;br /&gt;|      20 |&lt;br /&gt;+---------+&lt;br /&gt;1 row in set (0.00 sec)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Well, I really need that column added to journals, so I better revert that migration via Rake, uncomment the add_column method, and re-Rake.  Here&#39;s what happens:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;C:\rails_apps\books&gt;rake db:migrate version=19&lt;br /&gt;(in C:/rails_apps/books)&lt;br /&gt;== CreateThemes: reverting ====================================================&lt;br /&gt;-- drop_table(:themes)&lt;br /&gt;   -&gt; 0.0500s&lt;br /&gt;-- remove_column(:journals, :theme_id)&lt;br /&gt;rake aborted!&lt;br /&gt;Mysql::Error: Can&#39;t DROP &#39;theme_id&#39;; check that column/key exists: ALTER TABLE journals DROP `theme_id`&lt;br /&gt;&lt;br /&gt;(See full trace by running task with --trace)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Oops!  The self.down method is crapping out because there is no column in journals called theme_id.  (Of course, we knew that.)  Let&#39;s checkout the database now:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;mysql&gt; show tables;&lt;br /&gt;+--------------------------------------+&lt;br /&gt;| Tables_in_books_development          |&lt;br /&gt;+--------------------------------------+&lt;br /&gt;| journals                             |&lt;br /&gt;| schema_info                          |&lt;br /&gt;+--------------------------------------+&lt;br /&gt;2 rows in set (0.01 sec)&lt;br /&gt;&lt;br /&gt;mysql&gt; select * from schema_info;&lt;br /&gt;+---------+&lt;br /&gt;| version |&lt;br /&gt;+---------+&lt;br /&gt;|      20 |&lt;br /&gt;+---------+&lt;br /&gt;1 row in set (0.00 sec)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Do you see that schema_info still says version 20.  I presume that the last thing a migration does is update the schema_info.version with the idea being that we don&#39;t modify the version until we sure that the migration has succeeded.  The problem with that is that migrations aren&#39;t transactional--that is, they can complete  or fail partially, yet the schema_info is updated as though it were a transaction.  I don&#39;t know how Rails fixes this, but it&#39;s something worth knowing about.&lt;br /&gt;&lt;br /&gt;Anyhow, at this point my database is in limbo...neither in version 19 nor 20.  When I run &lt;pre&gt;rake db:migrate&lt;/pre&gt; nothing happens because as far as Rake can tell, the DB is up-to-date.  But, I can&#39;t run &lt;pre&gt;rake db:migrate version=19&lt;/pre&gt; either because Rake will error out because there is no theme table to drop.&lt;br /&gt;&lt;br /&gt;Okay, so the short-term solution to this problem is to clean-up the database manually.  In my case, everything was actually reverted in the self.drop, but Rake doesn&#39;t know that.  In your case you may have more manual clean-up to do.  So, all I needed to do was update schema_info.version to 19.</description><link>http://progress-vs-perfection.blogspot.com/2007/09/reverting-migrations-selfdrop-issue.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-30954145.post-2376009723721701332</guid><pubDate>Mon, 17 Sep 2007 20:37:00 +0000</pubDate><atom:updated>2007-09-17T13:39:31.072-07:00</atom:updated><title>Netscape Navigator 1.0</title><description>I&#39;m not getting much work done today...my desk and office are a mess, so I&#39;m working at cleaning up.&lt;br /&gt;&lt;br /&gt;While doing so, I found &lt;a href=&quot;http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&amp;item=290161888711&quot;&gt;a bit of history&lt;/a&gt; in my desk, and &lt;a href=&quot;http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&amp;item=290161888711&quot;&gt;you can have it&lt;/a&gt;.</description><link>http://progress-vs-perfection.blogspot.com/2007/09/netscape-navigator-10.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-30954145.post-1851107724804524294</guid><pubDate>Tue, 11 Sep 2007 20:15:00 +0000</pubDate><atom:updated>2007-09-11T14:27:51.858-07:00</atom:updated><title>Create Action Requires POST</title><description>UPDATE: I wrote the whole post below, and then I figured it out...oy, the risks of auto-generated code.  Typically, I use &lt;code&gt;script/generate scaffold&lt;/code&gt; to build my controllers and views, then I start modifying from there.  The risk of using auto-generated code is that you don&#39;t know every detail...and, if you&#39;re gonna own a program, you gotta know ever detail.&lt;br /&gt;&lt;br /&gt;Long story short: I started digging around at &lt;code&gt;.../verification.rb&lt;/code&gt; and I finally ended up back at my own controller and found this that scaffold sticks this bit of code in at the top of every controller:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;  # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)&lt;br /&gt;  verify :method =&gt; :post, :only =&gt; [ :destroy, :create, :update ],&lt;br /&gt;         :redirect_to =&gt; { :action =&gt; :list }&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;which is why I wasn&#39;t able call create with a GET.  Yikes!&lt;br /&gt;&lt;br /&gt;&lt;hr&gt;&lt;br /&gt;&lt;br /&gt;Boy, what a morning!  I found a &quot;feature&quot; of Rails that I don&#39;t quite understand yet, but it certainly caused me a lot of headache.  Maybe somebody else who is frustrated will benefit from this information.&lt;br /&gt;&lt;br /&gt;Long story short: if you are going to call the create action in a controller, then you can only do so via POST.  If you try to do so via GET you will get an error like the one below.  In other words:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;html&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt; &lt;span style=&quot;font-weight:bold;&quot;&gt;Form with POST method --&amp;gt; works&lt;/span&gt;&lt;br /&gt; &amp;lt;form action=&quot;/books/create&quot; method=&quot;post&quot;&amp;gt;&lt;br /&gt;  &amp;lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;submit&quot;&amp;gt;&lt;br /&gt; &amp;lt;/form&amp;gt;&lt;br /&gt;&lt;br /&gt; &lt;span style=&quot;font-weight:bold;&quot;&gt;Form with GET method --&amp;gt; does not work&lt;/span&gt;&lt;br /&gt; &amp;lt;form action=&quot;/books/create&quot; method=&quot;get&quot;&amp;gt;&lt;br /&gt;  &amp;lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;submit&quot;&amp;gt;&lt;br /&gt; &amp;lt;/form&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Apparently, Rails has some sort of before_filter that requires certain types of actions to be called via certain HTTP methods.  (Note: I am not using any of the Rails RESTful stuff, e.g. map.resources.)&lt;br /&gt;&lt;br /&gt;I have yet to figure out exactly what filter causes this requirement.  Also, I would be interested in knowing if there is a way to inspect all the before filters that will be run for a given action or controller.  If you know, please post in the comments.  &lt;br /&gt;&lt;br /&gt;Special thanks to &lt;a href=&quot;http://www.movesonrails.com/&quot;&gt;Dirkjan&lt;/a&gt; for helping me debug this far.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;From development.log&lt;/h3&gt;&lt;code&gt;Processing BooksController#create (for 127.0.0.1 at 2007-09-11 10:53:22) [GET]&lt;br /&gt;  Session ID: e042ea5ba771fd5423d39369ec8e1227&lt;br /&gt;  Parameters: {&quot;action&quot;=&gt;&quot;create&quot;, &quot;controller&quot;=&gt;&quot;books&quot;, &quot;journal_id&quot;=&gt;&quot;1&quot;}&lt;br /&gt;Redirected to http://localhost:3005/books/list&lt;br /&gt;Filter chain halted as [#&amp;lt;ActionController::Filters::ClassMethods::ProcFilter:0x47e198c @filter=#&amp;lt;Proc:0x0391ce4c@C:/InstantRails-1.7-win/InstantRails/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/verification.rb:74&amp;gt;&amp;gt;] returned false.&lt;br /&gt;Completed in 0.01000 (100 reqs/sec) | DB: 0.00000 (0%) | 302 Found [http://localhost/books/create?journal_id=1]&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Processing BooksController#list (for 127.0.0.1 at 2007-09-11 10:53:22) [GET]&lt;br /&gt;  Session ID: e042ea5ba771fd5423d39369ec8e1227&lt;br /&gt;  Parameters: {&quot;action&quot;=&gt;&quot;list&quot;, &quot;controller&quot;=&gt;&quot;books&quot;}&lt;br /&gt;   [4;36;1mBook Columns (0.010000) [0m    [0;1mSHOW FIELDS FROM books [0m&lt;br /&gt;   [4;35;1mSQL (0.000000) [0m    [0mSELECT count(*) AS count_all FROM books  [0m&lt;br /&gt;   [4;36;1mBook Load (0.000000) [0m    [0;1mSELECT * FROM books LIMIT 0, 10 [0m&lt;br /&gt;Rendering  within layouts/books&lt;br /&gt;Rendering books/list&lt;br /&gt;Completed in 0.03000 (33 reqs/sec) | Rendering: 0.01000 (33%) | DB: 0.01000 (33%) | 200 OK [http://localhost/books/list]&lt;br /&gt;&lt;/code&gt;</description><link>http://progress-vs-perfection.blogspot.com/2007/09/create-action-requires-post.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-30954145.post-4820586186070657947</guid><pubDate>Mon, 10 Sep 2007 23:36:00 +0000</pubDate><atom:updated>2007-09-11T13:15:27.972-07:00</atom:updated><title>How to use IRC for Ruby on Rails (#rubyonrails)</title><description>14 years ago I used IRC to chat with people online about the Grateful Dead and Phish, but haven&#39;t since, and basically forgot about 99% of how it works.  &lt;br /&gt;&lt;br /&gt;Then, recently I wanted to join the #rubyonrails IRC channel to get some instant information, so from http://www.rubyonrails.com/community I learned that #rubyonrails was hosted at irc.freenode.net.  I downloaded ChatZilla and tried to join.&lt;br /&gt;&lt;br /&gt;Frustration.  #rubyonrails requires some sort of nickname registration and it took me the &lt;span style=&quot;font-style:italic;&quot;&gt;longest&lt;/span&gt; time to figure out how the heck it works.&lt;br /&gt;&lt;br /&gt;I searched for documentation and found all sorts, but what I was found was very dry and technical and full of details.  Typically, I like that type of stuff--bare bones, just the facts.  &lt;br /&gt;&lt;br /&gt;But, here I needed the dummies course, and I found it at http://www.zymic.com/irc.php.  I can&#39;t vouch for that site, but thank goodness they had some basic info...it wasn&#39;t 100% correct, but it got me close enough.&lt;br /&gt;&lt;br /&gt;In ChatZilla &gt; Preferences &gt; General there is a &quot;nickname&quot; setting.  When you connect to irc.freenode.net you need to register this nickname...obviously, it should be something sort of unique.  (How to connect? Open Firefox and visit the URL irc://irc.freenode.net ...which should launch ChatZilla.)&lt;br /&gt;&lt;br /&gt;After ChatZilla connects to irc.freenode.net, you will need to register your nickname, aka &quot;nick&quot;.  To register the nick, type:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;/msg nickserv register &lt;span style=&quot;font-style:italic;&quot;&gt;&amp;lt;yourpassword&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;where &lt;span style=&quot;font-style:italic;&quot;&gt;&amp;lt;yourpassword&amp;gt;&lt;/span&gt; is some password of your creation.  This will register your nickname with some sort of central registration database.&lt;br /&gt;&lt;br /&gt;Then, to enter the channel type:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;/join #rubyonrails&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;On subsequent visits to IRC, ChatZilla will send your username to nickserv, but you will need to &quot;identify&quot; yourself this time.  To do so, type:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;/msg nickserv identify &lt;span style=&quot;font-style:italic;&quot;&gt;&amp;lt;yourpassword&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Then, join the channel like you did before:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;/join #rubyonrails&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Personally, I think of it like this:&lt;ul&gt;&lt;br /&gt;&lt;li&gt;register = create a login&lt;br /&gt;&lt;li&gt;identify = login&lt;br /&gt;&lt;li&gt;join = enter a chat room&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;Hopefully, these instructions will help someone else out along the way.&lt;br /&gt;&lt;br /&gt;P.S.  By the way, the delay between posts is explained by the fact that I was out of town for a few weeks visiting family.</description><link>http://progress-vs-perfection.blogspot.com/2007/09/how-to-use-irc-for-ruby-on-rails.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>2</thr:total></item></channel></rss>