Change trendline to be an option of scatter_chart. To set a trendline add option <%= scatter_chart data, trendline: true %>