# Plugin if statement not working :(

**URL:** <https://www.ruby-forum.com/t/plugin-if-statement-not-working/123358>\
**Category:** Ruby\
**Created:** [December 17, 2007, 1:26am UTC](https://www.ruby-forum.com/t/plugin-if-statement-not-working/123358 "2007-12-17T01:26:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![envygeeks](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/e68b1a/32.png) [@envygeeks](https://www.ruby-forum.com/u/envygeeks)\
**Post date:** [December 17, 2007, 1:26am UTC](https://www.ruby-forum.com/t/plugin-if-statement-not-working/123358/1 "2007-12-17T01:26:28Z")

</div>

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
