Question

i am new to ruby and nanoc. I am trying to sort articles based on time. So I get more accurate results on my blog.

This is what I am using in my sorted_articles_time.rb file under /helpers/

def sorted_articles_time
  articles.sort_by do |a|
    attribute_to_time(a[:time])
  end.reverse
end

But then I get the error

NoMethodError: private method `sorted_articles_time' called for #<Nanoc::Site:0x007fd93b0a3f40>

What am I doing wrong ? And is there a way to overwrite the existing sorted_articles method ?

Thanks

UPDATE: I already have it initiated in the rake file. So I think my rake file is fine here.

time1 = Time.new
@time =  time1.inspect
Was it helpful?

Solution

Are you calling @site.sorted_article_times? If so, leave off the @site part. Helpers are intended to be called as functions, not as methods on @site.

OTHER TIPS

Use a scrope from your model. Check this activeactive_record_querying this is the best place to sort your articles.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top