I thought of a counter cache however one of the problems is I need to be
able to query by a date range as well in some of my charts and a counter
cache wouldn't work.
I almost have it working however I am getting a " returned around
each string which I believe is a javascript problem.
My code is
def training_count_by_initiative(startdate, enddate)
initiative_names = Initiative.all.select("id,name")
training_count =
Training.by_date(startdate,enddate).group(:initiative_id).count
initiative_name.map do |initiative|
[initiative.name, training_count[initiative.id] || 0]
end
end
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5d4c2c113e22c6047e397fb066e76a0f%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment