All threads / Limit CSV export by Day, Week and Month

Ask A Question

Notifications

You’re not receiving notifications from this thread.

Limit CSV export by Day, Week and Month

Sascha M. asked in General

Hi there,

is there an easy way to limit the results inside a CSV export to a specific time-frame, like day, week and month?

Thanks!

Hey Sacha, you would just want to use a where query to scope to a date range before calling to_csv on it. You may need to change it from all.each to scoped.each in order for Rails to respect the scope if it wants to override your where query. That should do it!

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 38,311+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.