From: Jordon Bedwell Date: 2007-12-17T09:28:17+09:00 Subject: Plugin if statement not working :( I'm having a bit of trouble with a Mephisto plugin that doesn't seem to want to work right. The articles_by_month_and_year won't detect an empty return at all. For example if they go to /archives/2007/08 and there are no articles it doesn't return a 404 and if they go to /archives/200(6|8|9) it doesn't return a 404 either. Can somebody help me figure out what I'm doing wrong? module MephistoFullArchives module MephistoController def self.included(base) base.send :alias_method_chain, :dispatch_archives, :full_archives end def dispatch_archives_with_full_archives if params['path'].length < 4 # 3 or Less # Year and Month + Archives render_liquid_template_for(:archive, 'section' => @section, 'articles' => articles_by_month_and_year); else # Return 404 on Day # Do people actually want archive links for days? if params['path'].length == 4 show_404 and return else # Anything else might be an archive # Let Mephisto deal with it. # On a general basis Mephisto does alright with it. dispatch_archives_without_full_archives end end end def articles_by_month_and_year archives = [] archives = @section.articles.find(:all, :include => :user, :conditions => ['contents.published_at IS NOT NULL'], :order => 'contents.published_at DESC') if @archives.nil? or @archives.empty? show_404 and return else @articles = archives end end end end -- Posted via http://www.ruby-forum.com/.