ruby

FXRuby segfaults on require

So I'm trying to get some ruby code a friend of mine wrote running on my laptop, but it segfaults every time I fire it up. After a little debugging, it looks like FXRuby is the culprit, and the behavior is trivially reproducible by typing require 'fox16' in to irb. I'm running OS X and my friend runs Linux, but anecdotally this code wo...

Bundler http auth support

does anyone know if Bundler supports http auth? I'm pretty sure rubygems does (I think i read that somewhere) but I don't see anywhere in the docs where I might specify a username/pwd for a particular repo I'm trying to run my own private gem server so as not to expose sensitive code ...

Has anyone successfully set up their email settings on EngineYard?

I am attempting to add email capabilities to my app (forgotten password, notifications, etc.) and I am using EngineYard for hosting. I have successfully configured email in my test environment but upon uploading to EY it seems to error out in Production. I don't pay for their support and the only resource is a bit vague (or beyond me). ...

Is there a way to use a Ruby loop inside of HAML's :javascript region?

Inside of HAML, can we have a loop inside the :javascript region? This will work: - 10.upto(20) do |i| :javascript document.getElementById('aDiv').innerHTML += '#{i}'; and this will not: :javascript - 10.upto(20) do |i| document.getElementById('aDiv').innerHTML += '#{i}'; can the code above also be made to work as well...

Ruby - Read file in batches

Hi, I am reading a file that is 10mb in size and which contains some id's. I read them into a list in ruby. I am concerned that it might cause memory issues in the future, when the number of id's in file might increase. Is there a effective way of reading a large file in batches? Thank you ...

How would I instruct extconf.rb to use additional g++ optimization flags, and which are advisable?

I'm using Rice to write a C++ extension for a Ruby gem. The extension is in the form of a shared object (.so) file. This requires 'mkmf-rice' instead of 'mkmf', but the two (AFAIK) are pretty similar. By default, the compiler uses the flags -g -O2. Personally, I find this kind of silly, since it's hard to debug with any optimization en...

Trying to execute netdom.exe from a ruby script or IRB does nothing

I'm trying to write a script that will rename a computer and join it to a domain, and was planning to call on netdom.exe to do the dirty work. However, trying to run this utility in the script (same results in irb) does absolutely nothing. No output, no execution. I tried with backticks and with the system() method. System() returns fals...

Regular expression in Ruby

Hi, Could anybody help me make a proper regular expression from a bunch of text in Ruby. I tried a lot but I don't know how to handle variable length titles. The string will be of format <sometext>title:"<actual_title>"<sometext>. I want to extract actual_title from this string. I tried /title:"."/ but it doesnt find any matches as it...

How to test the XML sent to a web service in Ruby/Rails

I'm looking for the best way to write unit test for code that POSTs to an external web service. The body of the POST request is an XML document which describes the actions and data for the web service to perform. Now, I've wrapped the webservice in its own class (similar to ActiveResource), and I can't see any way to test the exact XML ...

Rails 2.x http basic authentication

I'm trying to get basic http authentication working on my Rails app. I'm offering a simple REST interface served by a Rails server, only xml/json output. Every method needs authentication, so I put the authenticate filter in ApplicationController: class ApplicationController < ActionController::Base helper :all # include all helpers,...

validates_associated not honoring :if

I'm totally blocked on this. See this pastie for sample code: http://pastie.org/990040 The first test will fail. The user model validates an associated address model, but is only supposed to do it if a flag is true. In practice it does it all the time. What is going on? ...

multi threading python/ruby vs java?

i wonder if the multi threading in python/ruby is equivalent to the one in java? by that i mean, is it as efficient? cause if you want to create a chat application that use comet technology i know that you have to use multi threading. does this mean that i can use python or ruby for that or is it better with java? thanks ...

Creating an Admin directory in Rails

I've been developing the CMS backend for a website for a few weeks now. The idea is to craft everything in the backend first so that it can manage the database and information that will be displayed on the main website. As of now, I currently have all my code setup in the normal rails MVC structure. So the users admin is /users and vide...

Rails engines extending functionality

So I have an engine which defines some models and controllers. I want to be able to extend functionality of some models/controllers in my application (eg. adding methods) without loosing the original model/controller functionality from engine. Everywhere I read that you simply need to define controller with the same name in your applicat...

initializing variables in ActiveRecord's classes

How to initialize variables in ActiveRecord class? Variables here is the variables that are outside the scope of database such as: class Product attr_accessor :used end I want to initially assign @used initially to false, later if some person access the product, i will change @used to true First i thought of putting @used=false i...

Set date format in ruby model (sinatra/datamapper)

Hi, I have a ruby model that contains a date attribue which I'd like to be able to pass in as a parameter in the format dd/MM/yyyy. However, my sqlite3 db stores the data in yyyy-MM-dd format so when a date like 20/10/2010 gets passed in, it will not be read to the database. I am using the Sinatra framework and using haml for the mark...

accessing Ruby variable(from model or controller) in SASS

Is there a way to access Ruby variables in SASS or do I have to make a custom function for it? What I'm trying to do is to generate a stylesheet for each user so in the controller, I do something like: def show respond_to do |format| format.css{render :partial => "styles"} end end then in the view name _styles.haml I do this...

Tell me how to use ActiveRecord#afeter_add

Hey,Guys! Now I hava a problem,how can I make the callback#after_add receive a reference to the join model in a has_many :through association? my code like this: class Emergency has_many :departments, :through => :eme_references, :after_add => Proc.new { |eme_reference| eme_reference.eme_flag = 1} end the attribute eme...

Installing rake

we tried to install rake on our pc but there were following errors.. We even tried updating gems but in vain. We need to run some tasks on rake and dont know how to go abt it. C:\Documents and Settings\nemanich\My Documents\gems>gem install rake-compi 0 .7.0.gem ERROR: http://gems.rubyforge.org/ does not appear to be a repository ER...

Is grouping your verification code in one Ruby method a bad idea?

Imagine I have a class like this: class A attr_accessor :a attr_accessor :b def check raise "a must meet some condition" if !condition(@a) raise "b must meet some condition" if !condition(@b) end def do_some_work check() # more work here end def do_some_more_work check() # othe...