ruby

irb history not working

in ~/.irbrc i have these lines: require 'irb/ext/save-history' #History configuration IRB.conf[:SAVE_HISTORY] = 100 IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history" and yet when i run irb and hit the up arrow nothing happens. also the irb history file specified is not getting created and nothing is logged to it. ...

email service that lets you programmatically create addresses?

I'm considering adding email addresses to a marketing web app. Currently users are able to sign up and get a subdomain address that they can choose (theychoose.domain.com). So I'm thinking of also offering [email protected] for an email address they can use. I've pretty much decided on sendgrid.com for sending email through the web ...

Acts_as_Inviteable Plugin not sending out invites in Ruby on Rails

Hi, I have been trying to create beta invites that each existing user can send out and was hoping to be able to use a plugin called acts_as_inviteable http://github.com/brianjlandau/acts_as_inviteable I was wondering if anyone had direct experience with it. When I checked the console, it appears to be creating the right queries, but n...

How do I do a parse, lookup, and assign foreign key on a signup page?

Hi, needing some help to just break down the problem. I have new users who will put in User.Email in a signup process. (I am using Ruby on Rails). For any given email, I want to parse out the @domain portion. I then want to find in a different model, Companies, the company_id with the matching column for @domain. I want to return th...

Customize Node Names in Ruby's Builder

I'm building a tool that generates dynamic xml. As a result my Models have pretty generic names: Project has_many :Groups Group has_many :Items has_many :Groups belongs_to :Project Item has_many :Params belongs_to :Group Param belongs_to :Project belongs_to :Group belongs_to :Item So when I build...

How to cast 1 and 0 to true and false in Ruby. Want a boolean or logical out.

I need to index into a hash that I have defined in terms of "true" and "false" colorHash = Hash.new { |hash, key| hash[key] = {} } colorHash["answers"][true] = "#00CC00" colorHash["answers"][false] = "#FFFFFF" For testing purposes, I am indexing with rand(2) and that fails. If I index with true it works. I was looking for something...

mocking an error/exception in rspec (not just its type)

I have a block of code like this: def some_method begin do_some_stuff rescue WWW::Mechanize::ResponseCodeError => e if e.response_code.to_i == 503 handle_the_situation end end end I want to test what's going on in that if e.response_code.to_i == 503 section. I can mock do_some_stuff to throw the right type of ...

"Real" and non-embedded use of Ruby, Python and their friends

Hello! So I'm aware of the big ammount of general-purpose scripting languages like Ruby, Python, Perl, maybe even PHP, etc. that actually claim being usable for creating desktop applications too. I think my question can be answered clearly Are there actually companies using a special scripting language only to create their applicatio...

Wrong JPEG library - ruby on rails- OS X

I keep getting this error any time i call any page that has a call that uses RMagick, but i can't figure out what library i'm missing, or what i need to install to get rid of this error. Does anyone have debugging suggestions? Processing SimpleCaptchaController#simple_captcha (for 127.0.0.1 at 2010-01-14 14:24:24) [GET] Parameters...

Metric-Fu/Rcov "No File To Analyze"

I'm trying to get metric-fu running on a rails project I'm working with. Every time it runs the rcov portion of the metrics I get: ** Invoke metrics:all (first_time) ** Execute metrics:all No file to analyze was found. All the files loaded by rcov matched one of the following expressions, and were thus ignored: [/\A\/System\/Library\/F...

Grabbing snapshots from webcams in ruby

How can I take snapshots from a webcam in ruby? I know the webcam device is on /dev/video0, but how do I get a picture from it? ...

Contact form in ruby, sinatra, and haml

I'm new to all three, and I'm trying to write a simple contact form for a website. The code I have come up with is below, but I know there are some fundamental problems with it (due to my inexperience with sinatra). Any help at getting this working would be appreciated, I can't seem to figure out/find the documentation for this sort of...

Is there a better alternative to this Ruby idiom?

I'm finding myself writing this bit of code in my controllers a lot: params[:task][:completed_at] = Time.parse(params[:task][:completed_at]) if params[:task][:completed_at] Don't get hung up on what I'm doing here specifically, because the reasons change every time; but there are many circumstances where I need to check for a value in...

Replication to a redundant server with Rails?

I'm working on a Ruby on Rails/PostgreSQL web app that a mobile device communicates with. The mobile device has the ability to post to a primary server and geographically redundant secondary server at the same time. I would to replicate my user and profile data from the primary server to the secondary server instantaneously. Is ActiveRes...

Mongomapper query collection problem

When I define the User has_many meetings, it automatically creates a "user_id" key/value pair to relate to the User collections. Except I can't run any mongo_mapper finds using this value, without it returning nil or []. Meeting.first(:user_id => "1234") Meeting.all(:user_id => "1234") Meeting.find(:user_id => "1234") All return nil....

Is this a reasonable use for &&= in Ruby?

In SO question 2068165 one answer raised the idea of using something like this: params[:task][:completed_at] &&= Time.parse(params[:task][:completed_at]) as a DRYer way of saying params[:task][:completed_at] = Time.parse(params[:task][:completed_at]) if params[:task][:completed_at] where the params Hash would be coming from a (Rail...

How to Rename or Move Rails's README_FOR_APP

When I run rake doc:app in my Rails application root, the API docs are generated using /doc/README_FOR_APP as the home page. I would like to add a .rdoc extention to that file so it is properly rendered on GitHub. Even better, I would like to move it to the app root (/README.rdoc). Is there a way to do this in my Rakefile by modifying th...

Why ruby's(ver 1.9) pcap gem, hanging after accessing it?

Hello. Using ruby 1.9 and latest gem install pcap + fix for compiling (convert ->ptr/->len to _PTR/_LEN), i found that after doing simple code: require 'pcap' cap = Pcap::Capture.open_offline('1.dmp') cap.each { |pkt| p pkt.src; } exit Pcap gem not leaving block cap.each, i.e. output: ... 213.248.106.202 192.168.1.50 213.248.106.20...

Execute a binary file in ruby (on Heroku)

Is it possible to execute a little binary file (required for payment processing) with Kernel#exec from a ruby app hosted on Heroku ? Or do I need to switch to another rails hosting solution ? ...

How to get the width of terminal window in Ruby

Have you ever noticed that if you run rake -T in rails the list of rake descriptions are truncated by the width of the terminal window. So there should be a way to get it in Ruby and Use it. I'm printing some Ascii-art on the screen and I don't want it to be broken. therefore I need to find out the width of terminal at run time some ho...