What is the meaning of $$ in Ruby?
irb(main):002:0> $$ => 5052 What is the meaning of $$ in Ruby and How/Where to use it? I do googled it like $$ ruby, but couldn't get desired result. ...
irb(main):002:0> $$ => 5052 What is the meaning of $$ in Ruby and How/Where to use it? I do googled it like $$ ruby, but couldn't get desired result. ...
I've not seen this feature as a plug in and was wondering how to achieve it, hopefully using rails. The feature I'm after is the ability to rate one object (a film) by various attributes such as plot, entertainment, originality etc etc on one page/form. Can anyone help? ...
sprintf("%g", [float]) allows me to format a floating point number without specifying precision, such that 10.00 is rendered as 10 and 10.01 is rendered as 10.01, and so on. This is neat. In my application I'm rendering numbers using the Rails NumberHelper methods so that I can take advantage of the localization features, but I can't f...
I have spent the last month investigating and learning RoR and Python. I have been developing with PHP for the last few years, but the time has come to move on. To be honest I like both RoR as well as Python and currently leaning more towards RoR. My question is which language do you think is going to have more impact on the web over t...
in `gem_original_require': no such file to load -- haml (MissingSourceFile) but this gem already istalled. I have also plugin for this path :-/home/techvant/rails_app/techease/vendor/plugins/haml/init.rb this init file having following code : - begin require File.join(File.dirname(__FILE__), 'lib', 'haml') # From here rescue ...
So, I have the following code: def LSCPHandler.send_message(message, hostname, port) s = TCPSocket.open(hostname, port) s.print message ret = s.recv(1024) s.close LSCPHandler.parse_error(ret) return ret end Which works just fine, normally. The server I'm talking to returns the response pretty quickly, usually, and all is well. ...
I am looking into using MacRuby and am interested in it's ability to AOT compile ruby code down to an executable. I am wondering though whether this places a restriction on the code in any way? Is there a subset of ruby which is supported or can i go ahead and perform all the meta-magic i want and still have the code AOT compiled? ...
I am trying to model a very simple system, but the Rails way of doing this is escaping me. I'd like to have two entities, a User and a Bet. A bet has two users and a user has many bets. I'd like the creating User of the bet to be able to mark it as resolved (do any form of update/delete on it). My initial thinking was to have a User ac...
Hi there, I've been using Rspec for a while and for some reason am receiving errors on a controller called ReferencesController. The error says that I have to specify the controller name by either using: describe MyController do or describe 'aoeuaoeu' do controller_name :my I've tried both variations: describe ReferencesC...
I already know all about Linux. I would like to start developing part-time, and be able to fall back on it full time if need be. I am a techie looking make money quickly with the least hassle, doing something vaguely related to my hobbies. I've been thinking about Python because it's beautiful, useful, and I will come closer to learning...
I've been running both Ruby 1.8.7 and Ruby 1.9 for a few weeks now. I install Ruby 1.9 with the suffix 19, so that the interpreter, rake, gem, etc. commands are "ruby19", "irb19", "rake19", "gem19", etc. The 1.8.7 equivalents have no suffix and are thus defaults. I figure that's the simplest and most transparent way to manage two versi...
How do I get Ruby's Net::HTTP module to cancel a request? The call to http.finish below raises an error. I get the impression that the response object doesn't know that the connection was closed and still expects more data. EDIT: I want to avoid making a HEAD request. So, make a get request, unless content-type is html, cancel the requ...
I don't understand what is going on here. How should I feed gsub to get the string "Yaho\'o"? >> "Yaho'o".gsub("Y", "\\Y") => "\\Yaho'o" >> "Yaho'o".gsub("'", "\\'") => "Yahooo" ...
I love Ruby blocks! The idea behind them is just very very neat and convenient. I have just looked back over my code from the past week or so, which is basically every single ruby function I ever have written, and I have noticed that not a single one of them returns a value! Instead of returning values, I always use a block to pass the ...
Hi, I'm trying to use RadRails on Windows and it's works relatively smoothly. But, when i hit F5 in my browser i have to wait ~15 secondes to refresh the page. It's annoying because the CPU usage is around 5% and it's looks like RadRails is doing nothing, no debbuger activity, no sql connection and no server requests during the 15 seco...
I've implemented a directed graph in Ruby using RGL, just having difficulty figuring out how to, for a given node, find only the nodes with incoming connections and the nodes with outgoing connections. Perhaps I'm missing something simple. ...
there is a public class method to add field to mechanize form I tried .. #login_form.field.new('auth_login','Login') #login_form.field.new('auth_login','Login') and both gives me an error undefined method "new" for #<WWW::Mechanize::Form::Field:0x3683cbc> (NoMethodError) I tried login_form.field.new('auth_login','Login') which give...
Hi, I would like to turn a string with opening hours like this: "Monday-Friday>10:00-18:00;Saturday>12:00-17:00;Sunday>12:00-15:00" Into this: [ {:period => "Monday-Friday", :hours => "10:00-18:00"}, {:period => "Saturday", :hours => "12:00-17:00"}, {:period => "Sunday", :hours => "12:00-15:00"} ] I'm trying it with the String.sca...
Hi! I have implemented a ruby script that is capable of opening a word document through the Ruby WIN32OLE automation library and does a search and replace on some specified string. This script is running as a "service", or it is running on a windows server with a session that is allowed to be running forever, and I just push the 'X' in...
Hello! At the moment I'm having a look on Mechanize. I am pretty new to Ruby, so please be patient. I wrote a little test script: require 'rubygems' require 'mechanize' agent = WWW::Mechanize.new page = agent.get('http://www.google.de') pp page.title google_form = page.form_with(:name => 'f') google_form.q = 'test' page = agent.subm...