ruby - Access my model using a daemon on rails 3 -



ruby - Access my model using a daemon on rails 3 -

i have next script:

#!/usr/bin/ruby require 'rubygems' unless defined?(gem) require 'mongoid' include mongoid::document @classes = availability.where(:availability_date.gt => time.now.utc + 1.hours).to_a puts @classes.count

but get:

classes_notification.rb:6:in `': uninitialized constant availability (nameerror)

some help please, need create daemon send emails info on availability model.

thanks in advance.

update code

my script under app/script/user/remeber_classes.rb

how can access require file.dirname(file) + "/../../config/environment"

because i'm getting

/users/jeanosorio/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:126:in require': cannot load such file -- ./../../config/environments (loaderror) /users/jeanosorio/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:126:in require' remember_class.rb:5:in `'

you must include rails environment first add together require "path_to_the_application/config/environment" code

or

you can access database straight using mongo gem see

https://github.com/mongodb/mongo-ruby-driver/wiki/tutorial

ruby-on-rails ruby ruby-on-rails-3 daemon

Comments

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -