If I type this big integer:
puts 9997836544.class.to_s
and compile with ruby 1.86, it reports expectedly:
BigNum
while JRuby (1.1.4 in Netbeans) reports surprisingly:
Fixnum
I thought Java had a BigInteger class to correspond to the BigNum class in Ruby. If so, I would have expected JRuby and ruby to produce the same output.
...
Assume color = "orange";
Ruby:
puts("My favorite color is #{color.downcase() + 'ish'} -- at least for now.");
PHP:
print("My favorite color is {strtolower( $color ) + 'ish'} -- at least for now.");
The PHP version does not work like I would like it to. I'm not looking for any language wars, I just want to know if anyone knows of a...
Anyone have a list of rails plugins that are both stable and give you enough functionality to be worth the extra effort of supporting?
Edit:
I am mostly interested in the best, most complete list of plugins so I can use it the next I'm starting a rails app. I don't currently need a particular plugin.
...
I have a system that filters template files through erb. Using convention over configuration, the output files get created in a file hierarchy that mirrors the input files. Many of the files have the same names, and I was able to use the directories to differentiate them.
That plan worked until I needed to associate additional info wi...
Hello,
I'm trying to put a rails face on a legacy database. It is an old Sybase
11 database installation. I've gotten an ODBC connection working that
uses unixODBC and FreeTDS to work. I'm also using the
activerecord-odbc-adapter gem.
I've had to use set_table_name and set_primary_key to make it work so
far. However, none of the dynami...
Is it necessary to unit test ActiveRecord validations or they are well-tested already and hence reliable enough?
...
Hi all,
I use inheritance in my model. An event has different types:
Event < activity
Event < training
Event < game
I want to set session data to every event type like
game.user_id = session[:user_id]
training.user_id = session[:user_id]
activity.user_id = session[:user_id]
I want to avoid writing @game.user_id = session[:user_id]...
I'm having a problem where I have been able to add a project to CC.rb perfectly fine but when I start the service I get "Access Denied" messages each time it checks with Subversion for a newer version.
I'm running with --trace and running the exact command it is trying from the project's work directory:
svn --non-interactive log --limi...
How do you do a Remote HTTP Post (request) in ruby?
...
In the following ruby code, the output becomes: "x y"
x = "x %s"
y = "y"
z = "z"
print x % y %z
The %z is ignored.
I want the output to be "x y z".
To understand the possibilities and limitations of the syntax of Ruby, I want to use only the print command and the %s and % flags. I know how to do this using sprintf but I want to kno...
I'm trying to figure out how to rescue syntax errors that come up when eval()ing code in Ruby 1.8.6.
I would expect the following Ruby code:
#!/usr/bin/ruby
good_str = "(1+1)"
bad_str = "(1+1" # syntax error: missing closing paren
begin
puts eval(good_str)
puts eval(bad_str)
rescue => exc
puts "RESCUED!"
end
to produ...
I'm trying to test a controller and I got this error. I understand the error, but don't know how to fix it.
test: on CREATE to :user with completely invalid email should respond with
redirect
(UsersControllerTest):ActionController::RedirectBackError:
No HTTP_REFERER was set in the request to this action,
so redirect_to :back co...
I'm using the ruby daemon gem. Wondering how I can add some extra steps to the stop action? Was hoping I could detect stop was called, and add some extra code to it. Anyone know how I can accomplish this?
...
When using a multi-paradigm language such as Python, C++, D, or Ruby, how much do you mix paradigms within a single application? Within a single module? Do you believe that mixing the functional, procedural and OO paradigms at a fine granularity leads to clearer, more concise code because you're using the right tool for every subproble...
I need script to add quotes in url string from url.txt
from http://www.site.com/info.xx to "http://www.site.com/info.xx"
...
I'm consuming a data feed that has recently added a Unicode BOM header (U+FEFF), and my rake task is now messed up by it.
I can skip the first 3 bytes with file.gets[3..-1] but is there a more elegant way to read files in Ruby which can handle this correctly, whether a BOM is present or not?
...
I'm expecting this output:
output:xyz
But if I type the following:
a = ["x", "y", "z"]
print "output:" + a.each {|i| print i}.to_s
Why do I get an 'xyz' before the word output as well as after it?
xyzoutput:xyz
...
Hi all,
When running tests in Ruby's unit::test framework, is there a really easy way to specify, from the command-line, that only one test should be run (that is, specify the test class and test member variable)? If not, is there another framework that has this feature?
...
Is there a way to generate Ruby classes (maybe even ActiveResource classes) from an XSD so that they contain a way to serialize the classes to xml valid for the initial XSD?
I know that soap4r has xsd2ruby but it appears that the generated ruby classes cannot be easily serialized to xml.
...
I've never seen undef - or any thing else that allows you to undefine a method - in any other programming languages. Why is it needed in Ruby?
EDIT: I'm not arguing that there is anything wrong with this. I just don't understand the purpose of defining methods at runtime? What's the purpose of that? How is it used? I've never done this ...