The situation: I have multiple classes that should each hold a variable with a configuration hash; a different hash for each class but the same for all instances of a class.
At first, i tried like this
class A
def self.init config
@@config = config
end
def config
@@config
end
end
class B < A; end
class C < A; end
Bu...
I've been out of the Ruby world for a while (3 years), but I'm coming back for a project. I am now overwhelmed by all the gems available. Is there a list of gems by popularity/best gems? And where is the current list of all the gems?
...
This method:
def format_stations_and_date
from_station.titelize! if from_station.respond_to?(:titleize!)
to_station.titleize! if to_station.respond_to?(:titleize!)
if date.respond_to?(:to_date)
date = date.to_date
end
end
Fails with this error when date is nil:
NoMethodError (You have a nil object when you d...
How do I make an HTTP GET request with parameters in Ruby?
It's easy to do when you're POSTing:
require 'net/http'
require 'uri'
HTTP.post_form URI.parse('http://www.example.com/search.cgi'),
{ "q" => "ruby", "max" => "50" }
But I see now way of passing GET parameters as a hash using net/http.
...
I'm having trouble looking up documentation for Ruby in Textmate. I installed Ruby 1.9.1 to /usr/local/bin but when I use Ctrl+H to lookup a word using the Ruby bundle I get this error:
/Users/joshuaaburto/Library/Application Support/TextMate/Pristine Copy/Support/lib/web_preview.rb:101: warning: mismatched indentations at 'end' with...
In Shoes, I'd like to create a button that is initially hidden. I've tried passing :hidden => true as part of the button style, as well as calling @button.hide() after creating it, but it remains obstinately visible.
I've been able to work around this by not creating the button until I want it shown, but that requires checking to see if...
Since I am working with different Platforms and programming languages, I found there are many good libraries that are ported with different programming language than its original. For example JUnit and Log4j which has been ported into several different languages. Sometimes if I am already used to working with these libraries, I would fin...
Can anyone tell me what is the difference between build and new command on Rails?
...
Hi all.
Could you plz explain me how to correct this problem. I've installed rails edge on perfect working with 2.3.3 application and on attempt to launch server i've got (ruby 1.8.6)
$ ruby script/server
=> Booting Mongrel
=> Rails 3.0.pre application starting on http://0.0.0.0:3000
/Library/Ruby/Site/1.8/rubygems.rb:270:in `activate':...
Hello,
I am writing a ruby script to be used as Postfix SMTP access policy delegation. The script needs to access a Tokyo Tyrant database. I am using EventMachine to take care of network connections. EventMachine needs a EventMachine::Connection class that is instantiated by EventMachine‘s processing loop whenever a new connection is cr...
For the daemons' options :multiple => true , so, It allows me to start multiple instance of background process.
now, when run command stop it stop all background processes, How can i stop them individually?
Note: I know we can kill by pid but i want the ticker to at_exit as well.
...
I am using the selenium-client gem with Webrat and Cucumber to test a rails project. I have Cucumber set up pretty much as described here: http://wiki.github.com/aslakhellesoy/cucumber/setting-up-selenium
My problem is that Selenium is prevented from performing file uploads. Ideally I'd like to be able to replicate webrat's 'attach_file...
I'm trying to create a complex (from my opinion) form, but the process is going very hard.
I want the form to have 4 elements:
A list [of subjects] and a button [to delete selected subject from list];
A button and an associated input field ["Add subject" and field to add it, respectively];
I think a single form wouldn't be enough, an...
I am running bash in emacs on osx and its pulling gems from a different place then terminal.app
in bash:
which gem
/usr/bin/gem
in terminal:
which gem
/opt/local/bin/gem
How do I change the bash to match terminals?
...
e.g.: comma seperated in a single textfield: [email protected], mail2@someotherdomain, ...
...
I am developing a ROR app that relies on many custom Rake tasks.
What is the best way to test them?
...
I have no idea how to "metatize" this method, but I know it should be simple. The method looks like this
def check_sent=(value)
Date.parse(value) rescue @dates_bad = true
self.write_attribute(:check_sent, value)
end
This is for an ActiveRecord subclass. I would like to have these methods for all fields that I specify....
Is there any difference between p and puts in Ruby?
...
Hello, is there a way to add JavaScript support to mechanize so that it will handle simple redirection like "document.location.href="? TIA
...
I have errors in a model that are showing up in the view when accessed with @model.errors. However, they do not show up if I try to do
<%form_for @applicant do |f|%>
<%=f.error_messages%>
This is zero, freakily: <%=f.error_messages.length%>
But this is not: <%[email protected]%>
however, the errors are p...