ruby

Ruby Rails Time.change not working as I would expect...I have checked the docs!

I have a form that contains one date element and 3 time elements. This is because 3 time events will occur on one date, and I don't want the user to have to input that date 3 times. On the server side, I would like to combine the one date with the 3 times to get 3 datetime objects. I was thinking I could just do something like: time_...

hpricot with firebug's XPath

I'm trying to extract some info from a table based website with hpricot. I get the XPath with FireBug. /html/body/div/table/tbody/tr/td/table/tbody/tr[2]/td/table/tbody/tr/td[2]/table/tbody/tr[3]/td/table[3]/tbody/tr This doesn't work... Apparently, the FireBug's XPath, is the path of the rendered HTML, and no the actual HTML from the...

Pretty-printing C# from Python

Suppose I wrote a compiler in Python or Ruby that translates a language into a C# AST. How do I pretty-print this AST from Python or Ruby to get nicely indented C# code? Thanks, Joel ...

Are there any modules or built in functions to do error reporting in Ruby?

Just wondering if there was any built in way to handle error reporting in Ruby? PHP does it on its own, Perl and Python you can import modules to use. Levi ...

Rails with Memcache returning wrong cached object?

I have a fairly large Rails app, which uses memcached on a seperate server as its cache store. The problem is that I randomly get errors in the production environment which seem to indicate that memcached is returning an incorrect object. Examples: In this example, current_site is a helper method which accesses a method on the Site m...

AASM Gem broken by Rails 2.3.2?

Has anyone had any problems using the AASM state machine Gem with Rails 2.3.2? It was working fine for me but is now giving a NoMethodError: NoMethodError (undefined method `state' for #<Comment:0x25cb8ac>): /usr/local/lib/ruby/gems/1.8/gems/rubyist-aasm-2.0.5/lib/persistence/active_record_persistence.rb:231:in `send' /usr/local/lib...

Best way to require all files from a directory in ruby ?

What's the best way to require all files from a directory in ruby ? ...

Is there an equivalent of Log4J for Ruby, Log4Ruby?

I looked around and couldn't find one. Is there an equivalent of Log4X for Ruby? If not what's the best way to handle all the debug statements. I'm fairly new to Ruby. Thanks! ...

Why are methods in ruby documentation preceded by a pound sign?

This is something that has been bugging me for a while. When you see any ruby method printed in text, it usually appears as Class#method or #method Now, I would use Class.method Why are all ruby methods preceded by a pound sign? Is there any reason for it? Just curious. ...

no such file to load -- openid/extensions/sreg

I'm running ruby 1.8.6 and rails 2.3.2 on Mac OS X 10.5.6. I'm trying to get ruby script/server to work... I've waded through mysql and imagemagick installation, and I'm now faced with the following error: => Booting Mongrel => Rails 2.3.2 application starting on http://0.0.0.0:3000 /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31...

Rails Time difference in hours

Hello I am trying to get the difference in hours for two different Time instances. I get these values from the DB as a :datetime column How can I do this so that it includes the months and years as well in the calculation while ignoring or rounding the minutes? Can this only be done manually or is there a function to do this? Thank y...

How reliable is DRb?

Are there any issues to consider when using DRb for implementing an in-memory message queue and for synchronizing actions between processes? I heard that it could be unreliable, but haven't found anything on the web that confirms this assertion. In case it's relevant, these would be processes running with a rails app environment that...

Is double-checked locking safe in Ruby?

This article states that double-checked locking is unsafe on certain language/hardware combinations when a shared variable can be updated with a reference to an object that is only partially initialized. I was wondering: does this also apply to Ruby? Is this something that varies by the Ruby implementation on the platform that it is ...

How I can delete special characters?

Hi there! Now I practice deleting characters such as: input = input.gsub(/<\/?[^>]*>/, '') and for special characters, example ☻ or ™: input = input.gsub('&#', '') this leaves only numbers, ok. But this only works if the user enters a special character as a code, like this: &#153; My question: How I can delete special characters...

Ruby console alternative for IRB (Windows)

I am looking for some free light-weight GUI alternative for IRB console on windows. What I whould like to see: Area to write a script (so I can edit, run, edit...) Command line to play with current variables Output window to see results Intellisence Breakpoints/debugging is a plus Actually, some thing similar to powershell_ise.exe wh...

Integrate Shoes into Aptana Studio RadRails

How can I run my Carpet applications directly from Aptana Studio with RadRails? Setting the shoes.exe as VM/Interpreter won't work. ...

Control IRB through a named pipe (instead of STDIN/STDOUT)

Is it possible to run Ruby IRB ver a named pipe, so I can send commands and get results remotely? Generally I would like to utilize the IRB engine, while have a different UI (probably written with .Net). ...

Should I iterate through business objects from Views in a MVC application?

I'm wondering how many data access should I do in a View when using a MVC framework. For instance: In my application there is a page that shows a list of all my favorite artists and, for each artist, a list of all songs of that artist. The question is: Should I pass only the artist list to the View, or should I pass also all the data (a...

Ruby arrays - cannot access value

Hey, So I am doing a small, simple project for my class and for some reason I can't access a value using a variable. This is my class: (I am having problems with the getAnswer method, in particular the answerArray array) #Create random fact array class RandomFact def initialize() @randomNum = rand(5) end def getQuesti...

Best scripting language for web development

I have worked on some small web development projects where the server side languages have been PHP, Java and Lisp. Now I want to learn web development seriously. I don't want to use platforms based on PHP or Java. I also want to learn Python in general. Ease of implementation and learning value is more important to me than real-world imp...