I have such problem: I need to take all Users and its associated objects perform some actions with them. This file should be executed once a month (it is for payments). I’m programming in Windows, but server could be on *nix.
Here what I want to do in code:
@users = User.all
@emails ||= Array.new
@amounts||= Array.new
@users.each do |user|
emails.push(user.email)//array of emails
amounts.push(user.websites.amount)//it will be arrray of amounts
//then I will make post request, which I do can with static values
How I can use User.all ?
Can someone help me with this ?
I think you want to create a custom rake task for this in your Rails app. Look at this railscast on how to create a task.