Search code examples
ruby-on-railsmethodsrubygemsprivatevanity

Rails vanity gem custom metric error: private method `to_time' called


Hi I am trying to setup Vanity gem into a rail 3 application. I am creating a custom metric to experiment a bit.

So I created it following the suggestions on their website:

metric "Signups" do
  description "Signups completed"
  def values(from, to)
    (from..to).map { |i| 24 }
  end
end
  • The file is located at the right place and is loaded, vanity picks it up but somehow it looks like there is an internal error in the way vanity works.
  • Of course: those values are only there for a testing purpose, they will be replaced by real ones later.

I get the following error when running this experiment

enter image description here

Thank you!


Solution

  • There seems to be an error in the gem:

    in this file .rvm/gems/ruby-1.9.2-p290/gems/vanity-1.7.1/lib/vanity/templates/_metric.erb

    where we can read the following line

    js = data.map { |date,value| "['#{**date.to_time.httpdate**}',#{value}]" }.join(",")
      vanity_html_safe(%{<div class="chart"></div>
    

    if we change date.to_time.httpdate to date.to_s.to_time.httpdate it works.