Wiki.find_page fails on second loop

Added by Moritz Voss over 13 years ago

Hi! I am experimenting with some plugin and wiki macro code.

I have the following problem (I'm also a Ruby newb...): The code posted below executes fine if only one argument is given, but it fails on the second go (with a "Page not Found" being raised; despite the page existing).

Any ideas or explanations about what I am doing wrong here?

Redmine::WikiFormatting::Macros.class_eval do
    desc "Displays multiple wiki pages in multiple columns. Example:\n\n !{{multi(page1, page2, otherproject:page3)}}" 
    macro :multi do |obj, args|
        out = "" 
        args.collect do |p|
                page = Wiki.find_page(p.to_s, :project => @project)
                raise 'Page not found:' + p.to_s if page.nil? || !User.current.allowed_to?(:view_wiki_pages,$

                @included_wiki_pages ||= []
                raise 'Circular inclusion detected' if @included_wiki_pages.include?(page.title)
                @included_wiki_pages << page.title
                out = out + "<td>" + textilizable(page.content, :text, :attachments => page.attachments) + "</td>" 
        out = "<table><tr>" + out + "</tr></table>" 
        return out

Thanks in advance...

Replies (1)

RE: Wiki.find_page fails on second loop - Added by Felix Schäfer over 13 years ago

Have a look at your development.log to see where the error occurs.