README.md in rufus-scheduler-3.1.10 vs README.md in rufus-scheduler-3.2.0
- old
+ new
@@ -121,10 +121,12 @@
* [It doesn't work...](http://www.chiark.greenend.org.uk/~sgtatham/bugs.html)
* [I want a refund](http://blog.nodejitsu.com/getting-refunds-on-open-source-projects)
* [Passenger and rufus-scheduler](http://stackoverflow.com/questions/18108719/debugging-rufus-scheduler/18156180#18156180)
* [Passenger and rufus-scheduler (2)](http://stackoverflow.com/questions/21861387/rufus-cron-job-not-working-in-apache-passenger#answer-21868555)
+* [The scheduler comes up when running the Rails console](https://github.com/jmettraux/rufus-scheduler#avoid-scheduling-when-running-the-ruby-on-rails-console)
+* [I don't get any of this, I just want it to work in my Rails application](#so-rails)
## scheduling
Rufus-scheduler supports five kinds of jobs. in, at, every, interval and cron jobs.
@@ -1424,9 +1426,37 @@
```
The rufus-scheduler singleton is instantiated in the ```config/initializers/scheduler.rb``` file, it's then available throughout the webapp via ```Rufus::Scheduler.singleton```.
*Warning*: this works well with single-process Ruby servers like Webrick and Thin. Using rufus-scheduler with Passenger or Unicorn requires a bit more knowledge and tuning, gently provided by a bit of googling and reading, see [Faq](#faq) above.
+
+### avoid scheduling when running the Ruby on Rails console
+
+(Written in reply to https://github.com/jmettraux/rufus-scheduler/issues/186 )
+
+If you don't want rufus-scheduler to kick in when running the Ruby on Rails console, you can wrap your initializer in a conditional:
+
+```ruby
+#
+# config/initializers/scheduler.rb
+
+require 'rufus-scheduler'
+
+s = Rufus::Scheduler.singleton
+
+
+unless defined?(Rails::Console)
+ # only schedule when not running from the Rails on Rails console
+
+ s.every '1m' do
+
+ Rails.logger.info "hello, it's #{Time.now}"
+ Rails.logger.flush
+ end
+end
+```
+
+It should work for Ruby on Rails 3 and 4.
### rails server -d
(Written in reply to https://github.com/jmettraux/rufus-scheduler/issues/165 )