1

I'm fairly new to rails and I'm trying to set the pointStart date in lazy_high_charts to pull the created_at date from my database table. I get the following error when trying to format the date and I'm not sure why:

undefined method 'year' for "Nov 13, 2012":String

Here's my controller#index:

def index
authorize! :index, @user, :message => 'Not authorized as an administrator.'

@date = User.pluck(:created_at).first

@count = User.pluck(:sign_in_count)

@h = LazyHighCharts::HighChart.new('graph') do |f|
f.options[:title][:text] = "Number of Logins"
f.options[:chart][:defaultSeriesType] = "area"
f.options[:chart][:inverted] = false
f.options[:chart][:zoomType] = 'x'
f.options[:legend][:layout] = "horizontal"
f.options[:legend][:borderWidth] = "0"
f.series(:pointInterval => 1.day, :pointStart => @date.strftime("%b %d, %Y"), :name => 'Logins', :color => "#b00000", :data => @count)
f.options[:xAxis] = { :minTickInterval => 24 * 3600 * 1000, :type => "datetime", :dateTimeLabelFormats => { day: "%b %e"}, :title => { :text => nil }, :labels => { :enabled => true } }
  end
end

I've been messing with it for a while and this is the closest I could get.

1 Answer 1

2

Your are passing a string where you should be passing a date.

You might try this:

f.series(:pointInterval => 1.day, :pointStart => @date, :name => 'Logins', :color => "#b00000", :data => @count)
1
  • HAHA! Wow, I could have sworn I tried that and got a different error, but I guess not. ...one of those moments. Thanks for the help!
    – Desmond
    Jan 3, 2013 at 23:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.