Tuesday, December 27, 2011

Refreshing the column in rails


It may be possible that your database is shared with multiple applications and you data are frequently changing. You can manually refresh the object by:

stock = Stock.find_all
loop do
puts “price = #{price}”
sleep 60
stock.reload
end


3 comments:

  1. Hi, i got some doubts about rhosync, i wish u could help me, exactly i got some problems when i execute the command: rake rhosync:start i got this output.
    [07:45:47 PM 2012-01-07] Rhosync Server v2.1.14 started... :public is no longer used to avoid overloading Module#public, use :public_folder instead from /home/eder/.rvm/gems/ruby-1.9.2-p290/gems/resque-1.14.0/lib/resque/server.rb:11:in `' /home/eder/.rvm/gems/ruby-1.9.2-p290/gems/rhosync-2.1.14/lib/rhosync/model.rb:104:in `block in create': Missing required field 'user_id' (ArgumentError) from /home/eder/.rvm/gems/ruby-1.9.2-p290/gems/rhosync-2.1.14/lib/rhosync/model.rb:103:in `each' from /home/eder/.rvm/gems/ruby-1.9.2-p290/gems/rhosync-2.1.14/lib/rhosync/model.rb:103:in `create' from /home/eder/.rvm/gems/ruby-1.9.2-p290/gems/rhosync-2.1.14/lib/rhosync/api_token.rb:11:in `create' from /home/eder/.rvm/gems/ruby-1.9.2-p290/gems/rhosync-2.1.14/lib/rhosync/user.rb:61:in `create_token' from /home/eder/.rvm/gems/ruby-1.9.2-p290/gems/rhosync-2.1.14/lib/rhosync.rb:115:in `create_admin_user' from /home/eder/.rvm/gems/ruby-1.9.2-p290/gems/rhosync-2.1.14/lib/rhosync.rb:80:in `bootstrap' from /home/eder/.rvm/gems/ruby-1.9.2-p290/gems/rhosync-2.1.14/lib/rhosync.rb:267:in `initializer' from /home/eder/rhodes_projects/employee-server/application.rb:10:in `initializer' from /home/eder/rhodes_projects/employee-server/application.rb:27:in `' from /home/eder/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' from /home/eder/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' from /home/eder/rhodes_projects/employee-server/config.ru:27:in `block in ' from /home/eder/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.6/lib/rack/builder.rb:51:in `instance_eval' from /home/eder/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.6/lib/rack/builder.rb:51:in `initialize' from /home/eder/rhodes_projects/employee-server/config.ru:1:in `new' from /home/eder/rhodes_projects/employee-server/config.ru:1:in `' from /home/eder/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.6/lib/rack/builder.rb:40:in `eval' from /home/eder/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.6/lib/rack/builder.rb:40:in `parse_file' from /home/eder/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.6/lib/rack/server.rb:200:in `app' from /home/eder/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.6/lib/rack/server.rb:301:in `wrapped_app' from /home/eder/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.6/lib/rack/server.rb:252:in `start' from /home/eder/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.6/lib/rack/server.rb:137:in `start' from /home/eder/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.6/bin/rackup:4:in `' from /home/eder/.rvm/gems/ruby-1.9.2-p290/bin/rackup:19:in `load' from /home/eder/.rvm/gems/ruby-1.9.2-p290/bin/rackup:19:in `' [EOF - dtach terminating]

    i got rhosync 2.1.14
    If you read this and you could help me, could be really helpfull for me.
    Thanks for all
    Eder Santander

    ReplyDelete
  2. @Eder try to reset your rhosync from admin console and reset database from application

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete