Skip to content

Commit

Permalink
add readme section about defined?(Rails::Console)
Browse files Browse the repository at this point in the history
gh-186

[ci skip]
  • Loading branch information
jmettraux committed Dec 15, 2015
1 parent 8decf81 commit 1b3c79a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions CREDITS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

== Feedback

- Eduardo Maia - https://github.com/emaiax - rufus and the Rails console
- Suisea - https://github.com/suisea - readme rewording
- Radek - http://stackoverflow.com/users/250422 - gh-166
- Patrik Ragnarsson - https://github.com/dentarg - timeout vs nil, gh-156
Expand Down
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1427,6 +1427,34 @@ The rufus-scheduler singleton is instantiated in the ```config/initializers/sche

*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 )
Expand Down

0 comments on commit 1b3c79a

Please sign in to comment.