我有一个activerecord方法,可以查找本周的所有事件,
myevents.map { |x| x.start_date.day => [x.title]}
(start_date是一个日期时间字段,标题是一个字符串),它给了我一个哈希数组;
[{11=>["40"]}, {11=>["0"]}, {11=>["0"]}, {11=>[""]},
{11=>["0"]}, {11=>["0"]}, {11=>["33"]}, {12=>["9"]},
{11=>["34"]}, {11=>["29"]}, {11=>["8"]}, {11=>["31"]},
{11=>["40"]}, {11=>["34"]}]
Run Code Online (Sandbox Code Playgroud)
我想映射值,所以我得到一个看起来像的数组;
[ {11=>[ average of values that occur on the 11th]},
{12=>[average of values that occur on the 12th]} ]
Run Code Online (Sandbox Code Playgroud)
但我不太清楚如何得到它.
如何从html.erb调用JavaScript函数
在application.js中
function displayClock() {
var digital = new Date();
var hours = digital.getHours();
var minutes = digital.getMinutes();
var seconds = digital.getSeconds();
var amOrPm = 'AM';
if (hours > 11) amOrPm = 'PM';
if (hours > 12) hours = hours - 12;
if (hours == 0) hours = 12;
if (minutes <= 9) minutes = '0' + minutes;
if (seconds <= 9) seconds = '0' + seconds;
dispTime = '<b>'+hours + ':' + minutes + ':' + seconds + …Run Code Online (Sandbox Code Playgroud) 谁能解释一下我的问题是什么:
ActiveRecord::Base.connection.select_values('SELECT c.value FROM custom_values c,
time_entries p, custom_fields cf where c.customized_type = 'TimeEntry'
and p.id = c.customized_id and c.custom_field_id = cf.id
and cf.type = 'TimeEntryCustomField' and cf.name = 'Reference TS Client'
and p.id = '+ log.user.id.to_s +' ;')
Run Code Online (Sandbox Code Playgroud)
我只是为"c.customized_type"得到了这个错误.可能是什么问题?