ruby

Ruby not selecting correct overloaded method...

Hey, Ive got a simple Nunit runner for a rake script i have: module NUnitRunner @NUnitPath = "#{RootDir}/tools/nunit/nunit-console.exe"; def self.RunTests(testFile) system("\"#{@NUnitPath}\" ? \"#{testFile}\"") end def self.RunTests(testFile, runArgs) system("\"#{@NUnitPath}\" ? \"#{testFile}\" #{runA...

RSpec - generic failure message instead of useful output

This is using RSpec2 - no matter what happens I seem to get the following error when an expectation is not matched. I'm sure (though I cannot try for a while) in version 1 the following code would state that the method 'methods' was not called. The code snippet below demo's this problem - when un-commenting the method in initialize, the...

Activerecord removes all zeros from the timestamp field.

Hi, I am using Ruby on rails. I am trying to retrieve timestamp column from particular table. Activerecord returns me the date, if timestamp contains all zeros. e.g: If timestamp stored is 2010-09-06 00:00:00:000, it returns me 2010-09-06. But if I have 2010-09-06 00:00:20:000, it returns me in the expected format(i.e: 2010-09-06 00:...

Unable to install plugin in Rails

I'm running Windows 7 32 bit. I just installed Ruby 1.9.2 and Rails 3.0.1. I set up my rails sample application and everything seems to be working fine. I tried installing the restful_authentication plugin from github and it's been a nightmare. I'm executing the following command: rails plugin install -force git://github.com/technoweeni...

Get inexistent system user info without the output

This is my code for getting all system users: def get_all_system_users user_paths = Dir["#{ENV['HOME']}/../*"] users = user_paths.map { |path| path.split("..")[-1].gsub(/\W/, '') } users.select { |user| %x{id #{user}}.include?("uid") } end The problem is the id #{user} command which returns an output for inexistent users that b...

Ruby threading pass control to main

Hi, I am programming an application in Ruby which creates a new thread for every new job. So this is like a queue manager, where I check how many threads can be started from a database. Now when a thread finishes, I want to call the method to start a new job (i.e. a new thread). I do not want to create nested threads, so is there any wa...

Rails times oddness : "x days from now"

Hi all. when users sign up to one of my sites for a free trial, i set their account expiry to be "14.days.from_now". Then on the home page i show how many days they have remaining, which i get with: (user.trial_expires - Time.now)/86400 (because there are 86400 seconds in a day, ie 60 * 60 * 24) The funny thing is, this comes out ...

Sendinx faxes via Aterisk/Adhearsion/etc

Are there any HOWTO's? I want to send and recieve faxes in my rails app. So I'm looking for books/articles/libraries to read ...

Profile a delayed_job task in a Ruby on Rails app/Memory leak

Hi, One of my delayed_job tasks has a serious memory leak and I'm having a hard time solving it. Can anyone recommend a good tool for profile a delayed_job task in order to solve this memory leak? Regards, Rubem ...

Is is possible to run Cucumber in Java out of the box without JRuby/gems?

Heya. I am new to Cucumber, JRuby, Gems and how it works. I like the idea of writing down the test case in plain English, but I am not keen on installing a lot of new tools (I really really like Java), just to get Cucumber up and running. So I have a few questions. 1) Do I need install JRuby/Ruby to use Cucumber in Java? No way to av...

how to display content with raw html

Hi, @post.body has following content (which is converted from Markdown by using RDiscount).How should I render it to the user in what it means? i.e I want to render it as strong text emphasized text... <p><strong>strong text</strong> </p> <p><em>emphasized text</em> </p> <blockquote> <p>this is a quote</p> </blockquote><p><img src="ht...

Certificate errors when using Devise with Facebook Oauth

Hi all- I'm using devise with oauth and Rails 3 (ruby 1.9.2) to log user's into my site. I followed this excellent blog post. That being said, I am getting a weird OpenSSL error, that seems to be due to some kind of certificate verification error. Heres what it looks like: OpenSSL::SSL::SSLError in Devise/oauth callbacksController#f...

Why is this not allowing any more method calls Ruby

When game.load is called and then game.addHit is called the ruby page stops loading at all yet if I don't call add Hit it doesn't and if I rename game.load to game.loadGame that doesn't load either. #!/usr/bin/ruby require 'rubygems' require 'mysql' class Game attr_accessor :id, :name, :urlName, :description, :hits, :categorys, :wid...

What is the purpose or here documents in ruby?

Hi, I have read about here documents on the book "The Ruby Programming Language" and didn't understand what is the purpose of here documents and when will you use it on production code. I would be happy if someone can explain and give some examples of usage. regards, ...

Repeatable randomness in Ruby

I know I can "restart" my rand calls by calling srand with a seed, but surely this would affect future calls to rand by other library methods, including cryptographic methods? How can I repeat my randomness in certain places and still ensure that the rest of my code isn't affected? ...

getting ActiveRecord::RecordNotSaved error while saving.

While creating a new object i am getting ActiveRecord::RecordNotSaved error on before_save. But i want to fetch the proper message other than ActiveRecord::RecordNotSaved error message. How may i fetch the proper error message and pass it to the rescue? begin #some logic raise unless object.save! rescue ActiveRecord::RecordNotSa...

Why use class << self in ruby?

Can you explain why the developer is using class << self to add a methods to the base class? base.rb from the GeoPlanet Gem module GeoPlanet class Base class << self def build_url(resource_path, options = {}) end end end ...

Encoding error in content get from open-uri in ruby on rails

Hi, Im some cases when I use open to get a web page in ruby the content of the page has an encoding error. Exemple : open("http://www.google.com.br").read Chars like ç and ã are replaced by "?" How can I get the right chars ? thanks. ...

How do I fetch error message from this object ?

>> c.errors => #<ActiveRecord::Errors:0x3ee6758 @base=#<CsvHeader id: nil, csv_name: "kkk_version", model_name: "KkkVersion", delimite r_char: ",", run_sequence: 3, csv_usage: "L", header_row: "Y", default_file_name: "kkk_version.csv", default_directory_nam e: "public/uploads", each_row_instance_method: "junk", on_complete_class_method: ...

Why can't we access local variable inside rescue ?

Local Variable begin transaction #Code inside transaction object = Class.new attributes raise unless object.save! end rescue puts object.error.full_messages # Why can't we use local varible inside rescue ? end Instance Variable begin transaction #Code inside transaction @object = Class.new attributes rais...