chartkick why is x-axis a date - ruby-on-rails

I've created a custom hash but the x-axis is showing up as a date. I want it to just show the value in the hash (1,2,3 etc...). This is my first time using chartkick so I'm lost as to why this is happening.
What's being displayed is January 1, 2000 with the value of 504, February 1, 2000 with value of 499, March 1 etc....
When I set #chart_hash as an array, instead of a hash (which is what is shown below), I get times in the x-axis instead of dates.
application.html.erb
<head>
<title>SampleApp</title>
<%= javascript_include_tag "//www.google.com/jsapi", "chartkick" %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
_chart.html.erb
<%= line_chart #chart_hash %>
#chart_hash
{0=>504, 1=>499, 2=>499, 3=>504, 4=>509, 5=>514, 6=>514, 7=>521.5, 8=>516, 9=>511, 10=>511, 11=>511, 12=>506, 13=>501, 14=>501, 15=>506, 16=>511, 17=>516, 18=>511, 19=>518.5, 20=>522.5}

Answer: In the past chartkick could only use date objects, but now if you pass the discrete option it will use regular numbers.
_chart.html.erb
<%= line_chart #chart_hash, discrete: true %>

Related

How to use datepicker in rails without gem?

I have tried with gem datepicker, but i have to use datepicker without any gem of datepicker?
i have added datepicker js files like
bootstrap-datepicker.ja.js
bootstrap-datepicker.js
this file i have loaded in view(erb)
<%= javascript_include_tag 'locales/bootstrap-datepicker.ja.js', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'bootstrap-datepicker.js', 'data-turbolinks-track' => true %>
but it's not working giving error like
in console:
ActionView::Template::Error (bootstrap-datepicker.js):
error on page:
Sprockets::Rails::Helper::AssetNotPrecompiled in MUser#index
bootstrap-datepicker.js
Check if you have jquery included, otherwise you cannot use bootstrap.
try adding <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> in your view above the other two scripts.
So your code should look something like this:
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<%= javascript_include_tag 'locales/bootstrap-datepicker.ja.js', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'bootstrap-datepicker.js', 'data-turbolinks-track' => true %>
You could also have a look at <%= form.date_field :date_attribute %> - it will use a native date picker, supported by all major browsers.
See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date
<%= form.date_field :date, attribute: 'date' %>
where the :date is your model

JSON Parser Error Unexpected Token Error Rails

I recently cloned my Rails app, which was developed on Linux, to my Windows OS. There were a few errors, and I managed to fix most of them except this one. This error pops up when I try to access my page locally:
JSON::ParserError
419: unexpected token at ''
This is the code in question:
<head>
<title>DemoApp</title>
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
<%= javascript_include_tag "ckeditor/ckeditor.js" %>
<%= csrf_meta_tags %>
I researched and couldn't find a straightforward solution to this. I had previously changed my runtimes.rb to 'UTF-8' so that it will run in Windows.
Any help is much appreciated.
It could be because of a BOM or a tabulation space, it happens to me when I try to paste inside Vim.

Errno::ENOENT in Devise::Sessions#new

I'm using rails 5 to create a Facebook clone as a project and I periodically get an 'Errno::ENOENT in Devise::Sessions#new' error sometimes when I start the local server. I haven't yet experienced the problem on my production server. The problem goes away once I refresh the page.
The extracted source code is below. The line that starts stylesheet_link_tag is highlighted.
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
No such file or directory # rb_file_s_rename - path/facebook/tmp/cache/assets/sprockets/v3.0/Ej/EjoE1YdPTMb8n3_nucZiHWaR9FpoOSZttfl56_miOS0.cache.47161664401480.4109.232718, path/facebook/tmp/cache/assets/sprockets/v3.0/Ej/EjoE1YdPTMb8n3_nucZiHWaR9FpoOSZttfl56_miOS0.cache)

Rails turbolinks affect my content layout

When I enabled the turbolinks in my rails app, some of the content layout been affected and not aligned properly. But if I refresh the page then the content is aligned properly.
After adding turbolinks,
remove below Two link in views/applicatios.html.erb
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
it works for me..

Bootstrap Gem Installation Issue

I have added the bootstrap-sass gem and have installed the bundle. I have gone to github and think I have followed the directions correctly to finish the install for ruby on rails. It doesn't appear to be making a difference however on my local site - no font/formatting changes have been made, even after the install.
I am using a PC, https://github.com/findingtheway/pin
Change your app/views/layouts/application.html.erb to this:
<head>
<title>Pin</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
Rails uses application by default you have default which is why bootstrap is not loading.

Resources