List all types declared by module in Ruby
How can I list all the types that are declared by a module in Ruby? ...
How can I list all the types that are declared by a module in Ruby? ...
My Invoice model has an address_id attribute, and I don't want this address_id to change FOREVER. So I don't want this to happen outside the class: invoice.address_id = 1 invoice.address = some_address Rails automatically adds this address_id attribute to the model from the invoice table, so how can I declare this attribute private/pr...
I have been looking at XML and HTML libraries on rubyforge for a simple way to pull data out of a web page. For example if I want to parse a user page on stackoverflow how can I get the data into a usable format? Say I want to parse my own user page for my current reputation score and badge listing. I tried to convert the source retri...
In C#, I can do this: class Program { static void Main(string[] args) { List<Animal> animals = new List<Animal>(); animals.Add(new Dog()); animals.Add(new Cat()); foreach (Animal a in animals) { Console.WriteLine(a.MakeNoise()); a.Sleep(); } } } publi...
Using Ruby and Thin as a web service. Apache is also loaded. Can't access the web service because listing ports, such as :3000 or :6600, in the GET url is not allowed. How is the port requirement removed? ...
I'm trying to learn Regex in Ruby, based on what I'm reading in "The Rails Way". But, even this simple example is stumping me. I can't tell if it is a typo or not... text.gsub(/\s/, "-").gsub([^\W-], '').downcase It seems to me that this would replace all spaces with -, then anywhere a string starts with a non letter or number followed...
What do you think about this build tool? I'm thinking of migrating from maven2 to raven (my poms are getting bigger and bigger), but I'd like to hear some opinions first. Thanks! @andre: Thank's for writing but I was actually looking for real experiences using raven. Anyway, the fact that nobody wrote is an indicator by itself (it see...
Has anyone used Ruby/Rails with a Sales Logix database? ...
I need to see if a given process id is running, and it must work in either Java or JRuby (preferably a Ruby solution). It can be system dependent for Linux (specifically Debian and/or Ubuntu). I already have the PID I am looking for, just need to see if it is currently running. UPDATE: Thanks for all the responses everyone! I appr...
I'd like the canonical way to do this. My Google searches have come up short. I have one ActiveRecord model that should map to a different database than the rest of the application. I would like to store the new configurations in the database.yml file as well. I understand that establish_connection should be called, but it's not clea...
i am working on a simple web app which has a user model and role model (among others), and an admin section that contains many controllers. i would like to use a before_filter to check that the user of the user in the session has a 'can_access_admin' flag. i have this code in the application.rb: def check_role @user = session[:user] ...
What's the best way to add a flash message, for successful or unsuccessful login when using the merb-auth slice (Other than overriding sessions create)? ...
I want to attach an xslt stylesheet to an XML document that I build with XMLBuilder. This is done with a Processing Instruction that looks like <?xml-stylesheet type='text/xsl' href='/stylesheets/style.xslt' ?> Normally, I'd use the instruct! method, but :xml-stylesheet is not a valid Ruby symbol. XMLBuilder has a solution for this ...
I am testing a Ruby Rails website and wanted to get started with Unit and Functional testing. ...
I have written a ruby script which opens up dlink admin page in firefox and does a ADSL connection or disconnection. I could run this script in the terminal without any problem. But if I put it as cron job, it doesn't fire up firefox. This is the entry I have in crontab # connect to dataone 55 17 * * * ruby /home/raguanu/Dropbox/netti...
Hi, I have used Perl for many years now, mostly for doing all kinds of file parsing and system scripting jobs. Several newer scripting languages (python, ruby) are now available, that all in part tend to address scripting etc. in a better way than Perl apparently did. If I would have to choose learning a new scripting language, which ...
Hi, this wiki page gave a general idea of how to convert a single char to ascii http://en.wikibooks.org/wiki/Ruby_Programming/ASCII But say if I have a string and I wanted to get each character's ascii from it, what do i need to do? "string".each_byte do |c| $char = c.chr $ascii = ?char puts $ascii end It doesn't wo...
I want to be able to run a single spec file's tests for the one file I'm editing, for example. rake spec executes all the specs. My project is not a Rails project, so rake spec:doc doesn't work. Don't know if this matters, but here is my directory structure. ./Rakefile ./lib ./lib/cushion.rb ./lib/cushion ./lib/cushion/doc.rb ./lib/...
I am trying to find a better way to integrate IRB with my normal ruby devleopment. Currently I rarely use IRB with my code. I only use it to verify syntax or to try something small. I know I can load my own code into ruby as a require 'mycode' but this usually doesn't mesh with my programming style. Sometimes the variables I wan...
I'm planning to write a program in Ruby to analyse some data which has come back from an online questionnaire. There are hundreds of thousands of responses, and each respondent answers about 200 questions. Each question is multiple-choice, so there are a fixed number of possible responses to each. The intention is to use a piece of demo...