Plugin if statement not working :(

Discussion in 'Ruby' started by Jordon Bedwell, Dec 17, 2007.

  1. 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'], :eek:rder =>
    '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/.
     
    Jordon Bedwell, Dec 17, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page