How to use 'Whenever' gem? - ruby-on-rails-3

I'm currently trying to use the whenever gem to schedule my tasks but I do not know how it works. I've tried following the steps at https://github.com/javan/whenever but I got stuck at schedule.rb file. What am I supposed to write inside here? I want my app to call a method every minute using this gem. How am I supposed to do it? Can anyone give me a clue on how to do so?
UPDATE
I did the following to my application whereby it's supposed to send out an email every minute. I tried running the method without the scheduling and it works but it doesn't work if i schedule it, like the codes below. Is there something wrong with my code?
1) schedule.rb
every 1.minute do
runner "Newsletter.schedule_email"
end
2) newsletter.rb
def schedule_email
...*codes*...
end

Well, the basic form would be:
every 1.minute do
runner "Class.method_name"
end
If your stuff isn't running, this question might have some useful info:
Whenever cron job is not working in rails 3
There's also a railscast about cron jobs in general and Whenever in particular:
http://railscasts.com/episodes/164-cron-in-ruby

Related

How to check the contents of postgres

I'm running tests with Matchstick and my save() calls don't seem to be working (I set up my tests by saving some entities, but then my application code doesn't see them when it goes to load).
Is there any way to check the current state of the backend and see what's in there? Mainly just trying to troubleshoot.
Turns out, you just have to read the docs
https://thegraph.com/docs/en/developer/matchstick/
logStore()

How To Stop Timer On function call react-native-timer-countdown

I have implemented react-native-timer-countdown package and it works fine just like given in the following example
https://github.com/avid21/react-native-timer-countdown
But I want the timer to stop on a function call rather when the mentioned time elapses.
Can this be done using this package? If not then please suggest me some other way by which I can do it.
Thanks In advance.

How to use Automated actions in Odoo 8?

I wanted to send emails a day(fewdays) before a particular due date.
I went on to try with automation actions and was confused with on how it would work
and also the server action for that respective automated action
I would like to know whether "based on timed condition" works or does not work, as far as I have tried and researched, this seems to be a bug or which does not work.
Automated Actions do work, and are quite useful.
One catch with timed conditions is that they are triggered once and only once for each document/record, when the time condition is reached for the first time.
If you are playing around with timed conditions and use the same document/record for your tests, it will seem that later tries don't work, since triggered once it won't be triggered again.
In this scenario, you need to test changes to the Automated Action using a different test record.
Other things that might be wrong:
Your outgoing email might not be working properly.
The filter in your Automated Action might not be correct. Make sure you test it on a list view, and that the "User" field is blank.

Paperclip and mongoid background processing

is there any gem for process paperclip jobs in background?
I found delayed_job and resque, but both are for active record not monogid
Regards,
i used sidekiq before and it was working fine doing the background jobs with paperclip... the only issue I had with it, is that sometimes (scenarios ) are really hard to implement or test using rspec.... like this issue but it was really a scenario not often used...( i want to fetch the image from url in background job)
there is also other solutions you can look into... it's not exactly doing the background job implementation ( it's a pubsub pattern implementation) like the following gems
wisper
wisper async
you can add events when on specific actions and respond to them in the background ( using wisper-async)
the benefits of using this wisper approach is that it provides simple pubsub pattern that works like background jobs... and it's the only background free solution that works with heroku... plus it provides a good solution to decouple and simplify your application
check this http://artmees.github.io/blog/2014/04/02/on-rails-pub-slash-sub-pattern/ for extra info on using pubsub pattern...
one last thing (I'm not sure about)... I think there are no problems using resque or delayed_job with mongoid... although I didn't try them.

Obj-C, how can I log to a file how long a method took in seconds?

I envisage I'll run into problems as i haven't done this before.
I'm thinking that I can either define a date at the start of the method or initialise a class.
Then at the end of the method, call the commit method, which will write the time taken about with some sort of code to determine where the measurement was made.
Since you're crashing before the app finishes launching, so no code is going to fix this. If TestFlightApp isn't working, any other code-based solutions are likely to have the same problem.
As #dasblinkenlight noted, NSLog timestamps, so that's a really easy first step. Then you need to get the logs.
If possible, have your user install and run the iPhone Configuration Utility. Have her connect her device and select it from the Devices list. Then select Console and "Save Console As..." She can then mail it to you.