Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Plugin if statement not working :
Jordon Bedwell
12/17/2007 12:28:00 AM
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-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Plugin if statement not working :
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password