You are here: Forums Ask a Rails expert how to get missing months...
Posted in Forums : Ask a Rails expert
Authority 25
Posting Rating 0
Sign in to rate this post
|
Hi, getting output like this
but i was missing the months Apr,Jul when there were no records in that months any help ?? thanks |
Authority 12
Posting Rating 96
Sign in to rate this post
|
You have two approaches there: the first is by appending the missing dates in Ruby (you may want to override the Array class for that), and the second one is by creating a year_months table and using it as a left join in your call to User.count. Your year_months table should look like this: id Where year_month contains the Month/Year combinations, i.e., “Jan 2008” to “Dec 2008”. EDIT: You can get rid of the id field if you have no need for it. |
Ask a Rails expert : calling functions from model to controller
Ask a Rails expert : calling functions from model to controller
Ask a Rails expert : rspec examples?
Ask a Rails expert : Radio buttons with Observe field
Ask a Rails expert : copy to clipboard
Ask a Rails expert : API call problem
Ask a Rails expert : Invoke a plugin from a plugin?
Ask a Rails expert : Restful problem