What properties file format can be read by both Ruby and PHP?
I want to store my database connection information in a single file, which both PHP and Ruby scripts can use. Should I use name-value pairs, yaml, xml, or something else? ...
I want to store my database connection information in a single file, which both PHP and Ruby scripts can use. Should I use name-value pairs, yaml, xml, or something else? ...
I'm simply trying to get a percentage. irb(main):001:0> (25 / 50) * 100 => 0 This should most definitely equal 50, as confirmed by my calculator (copied and pasted the same equation into gcalc). Why does Ruby refuse to do this? ...
Hello. I have recently written some complex ruby script that eventually fails with segfaults in random time and in random places, like nokogiri, mechanize, iconv, timeout. I've tried it under 1.9.1 p 129, 1.8.6 p 369 under windows 7 and 1.8.7 under ubuntu, still the same behavior. Since there are three actual versions (1.8.6, 1.8.7 and 1...
I have a string, containing an Class name. It is, for example, a string containing "Article". That string came up from the params[]. What should I do to work with this string as if it was a class name? For instance, I want to do: Article.all and so on. Any idea? ...
Taken from a previous post with some modifications to respond to sepp2k's comment about namespaces, I have implemented String#to_class method. I'm sharing the code here and I do believe that it could be refactored someway specially the "i" counter. Your comments are appreciated. class String def to_class chain = self.split "::"...
Are the same unit testing frameworks used for different web frameworks - Rails, Merb, Sinatra, Ramaze and desktop frameworks - Shoes? And what is the most widely used unit testing framework that would work with all of the various web and desktop frameworks? ...
I am a little confused by the sheer number of testing frameworks available for Ruby/ROR. I have recently watched the Cucumber Railscasts and found them very interesting. So I started having a play and then struggled to see conceptually where I would put various tests. It would seem to be quite possible to do everything that can be done...
How would you make a decision between cucumber and shoulda if you were about to choose a testing framework? What differentiates these two frameworks primarily? ...
I have an array.. [1,2,3,4] and I want a string containing all the elements separated by a newline.. 1 2 3 4 but when I try [1,2,3,4].join("\n") I get 1\n2\n3\n4 I feel like there is an obvious answer but I can't find it! ...
Hi, I was wondering how to add custom configuration variables to a rails application and how to access them in the controller, for e.g I wanna be able to define an upload_directory in the configuration files say development.rb and be able to access it in one of my controllers. Secondly I was planning to have S3 support for uploads in m...
Can I create a Rails model where the ID auto-increments from 0, not 1? How? Are there any gotchas? I checked here, and it seems I can't: http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#M001911 If, as it seems, I cannot, is there reason why I can't or shouldn't just manually assign an ID of 0 to ...
Hi. I use IE 8 OLE object from ruby to navigate to a certain page, than I select an image on the page. How to get its location and extension? OK, the image IS in cache, how to get it's name in cache? ...
I want to create a set of values in Ruby which I can store and retrieve in a MySQL databse under Rails. In Delphi I would use: //Create an enumeration with four possible values type TColour = (clRed, clBue, clBlack, clWhite); //Create a set which can hold values from the above enumeration TColours = set of TColours; //Create a var...
Hi, I'm trying to extract some information from an online xml weather resource (weather underground). I am able to open the resource and pull out the desired elements, but what I really want is to return the element text as a variable, without the containing xml element tags, so I can manipulate it and display it on a web page. Perhap...
Why this code 7.30 - 7.20 in ruby returns 0.0999999999999996, not 0.10? But if i'll write 7.30 - 7.16, for example, everything will be ok, i'll get 0.14. What the problem, and how can i solve it? ...
module M def f=(x) @f= x end def f @f end end class A extend M end class B < A end A.f= 42 puts A.f puts B.f this produces 42 nil Is @f a class variable to A and B? How do I share a variable between A and B by only writing this into M? ...
Hello, how can I read the %USERPROFILE% variable from ruby in windows seven? ...
I'm running windows xp and I've got MiniMagick and ImageMagick installed (latest versions). I'm now using the console to test out that everything works. Using the ms command prompt image magick works no problem. I'm testing this by using the identify command. Now, when I try to use MiniMagick from the console by entering image = MiniMag...
Does anybody have any code handy that center truncates a string in Ruby on Rails? Something like this: Ex: "Hello World, how are you?" => "Hel...you?" ...
I want to (efficiently) get the symbol an aliased method is called with at runtime. A direct efficient access to a stack frame object of some sort to get it would be the fantasy. ie: class Foo def generic_call(*args) puts("generic_call() was called by using #{???}") end alias :specific_call1 :generic_call alias :specific_...