ruby

Python vs Ruby Top Sites

Hi, I was just trying to find some comparison of the existing python web frameworks and ruby frameworks. There are few promising frameworks in python but I was not able to find a top 100 site using python except for google, which uses python extensively. Python has great frameworks but I am not able to find a really popular sites usin...

ruby socket programming using credentials

HI folks, I'm trying to establish connection to a remote server using ruby socket connection TcpSocket. I started with TcpSocket.new(port,host) Now, How do I pass the credentials to it. The remote server needs credentials to allow me to connect. Any help is very much appreciated. Thanks ...

how can I capture **http response** from twitter.com? ( ruby + twitter gem)

I opened a question how can I capture response from twitter.com? ( ruby + twitter gem) to know if my update was successful. It is working fine... But I would like to know how I can capture HTTP Response Codes and Errors inside my ruby code? oauth = Twitter::OAuth.new('consumer token', 'consumer secret') oauth.authorize_from_access('acc...

Failing to install activerecord-jdbcmysql-adapter gem

I am trying to follow the basic "Create a blog in 20 minutes" Rails screencast but have hit a stumbling block already. When I try to rake db:migrate I get errors about the gem activerecord-jdbcmysql-adapter not being installed. When I try to install it, I am told it doesn't exist. If I try to simply gem install mysql I get all sorts of...

NoMethodError for underscore

I want to convert the string "Full Time" to "full_time" When I using "Full Time".underscore in irb, it prompt a error NoMethodError: undefined method `underscore' for "Full Time":String How can I fix it? Or is there any other way for me to get the above underscored result? ...

What would you like to see in a book about Rails 3?

Hello, Now that I'm quite a ways into this book I can announce that it's Rails 3 in Action. I'm thinking of writing a book about Rails 3 and I have a basic idea of what I want to write about, but really what I need is that little bit of polish from the community. The book is planned to cover: A little bit of Ruby Version control usin...

Postgres database to mysql database conversion

Is there any ruby script for converting postgresql database to mysql database. I have secrhed lot many sites but i couldnt get that. Please suggest me ...

Retaining Form data after POST in Ruby on Rails

I need to retain the Form data submitted in one view to be used in another view. I'll be using POST method to submit the data. Is there anyway I can retrieve data from the POST method in Ruby, like in PHP I would use $title=$_POST["title"]. Any ideas? Thanks and Cheers ! ...

how can I handle "error" in communication to twitter.com? (ruby + twitter gem)

I have nice piece of code that works. I tried to tweet the same text and I my script ended because /lib/ruby/gems/1.8/gems/twitter-0.9.4/lib/twitter.rb:87:in 'raise_errors': (403): Forbidden - Status is a duplicate. (Twitter::General) I know I cannot tweet the same text twice but I thought I will get the error inside the response variab...

Ruby 1.8 regexp: index of match in utf string

I'm trying to search a text for a match and return it with snippet around it. For this, I want to find match with regex, then cut the string using match index +- snippet radius (text.mb_chars[start..finish]). However, I cannot get ruby's (1.8) regex to return match index which would be multi-byte aware. I understand that regex is one ...

How to access a (shadowed) global function in ruby.

Hi, I was wondering how to access a global function fn in ruby from a class which also defined a method fn. I have made a workaround by aliasing the function like so: def fn end class Bar alias global_fn fn def fn # how to access the global fn here without the alias global_fn end end I'm looking for some...

Parsing through email in Ruby using Action Mailer

I retrieve mail using net/pop , but I also need to parse through the email to obtain subject,from address and email body. Any ideas with Action Mailer? I'm supposed to use 3rd party gems.(No,not even Tmail) require 'rubygems' require 'net/pop' require 'pop_ssl' Net::POP3.enable_ssl(OpenSSL::SSL::VERIFY_NONE) def pull_mail Net::PO...

ruby: sum corresponding members of two arrays

I've got two (or more) arrays with 12 integers in each (corresponding to values for each month). All I want is to add them together so that I've got a single array with summed values for each month. Here's an example with three values: [1,2,3] and [4,5,6] => [5,7,9] The best I could come up with was: [[1,2,3],[4,5,6]].transpose.map{|ar...

api.rubyonrails.org is out?

Is just for me or the site http://api.rubyonrails.org/ and the whole rubyonrails.org domain are being redirected to a spam website? I just realized it today when i went to answer a question here at stackoverflow. ...

Database nesting model layout confusion

I'm no expert in databases and a beginner in Rails, so here goes something which kinda confuses me... Assuming I have three classes as a sample (note that no effort has been made to address any possible Rails reserved words issue in the sample). class File < ActiveRecord::Base has_many :records, :dependent => :destroy accepts_neste...

Finding records that overlap a range in Rails

So, I have an Event model that has a starts_at and a ends_at column and I want to find events that take place in a range of dates. I've come up with this named_scope (range is typically a month): named_scope :in_range, lambda { |range| {:conditions => [ 'starts_at BETWEEN ? AND ? OR ends_at BETWEEN ? AND ?', range.first, rang...

How do I set default search conditions with Searchlogic?

I've got a search form on this page: http://staging-checkpointtracker.aptanacloud.com/events If you select a State from the dropdown you get zero results because you didn't select one or more Event Division (checkboxes). What I want is to default the checkboxes to "checked" when the page first loads...to display Events in all Division...

Running python/ruby script on iPhone?

From the recent news from the Apple, I learned that one has to use C/C++/Objective-C for iPhone App. Accordingly, it's not possible to use MacPython or similar to make iPhone App. But as the python/ruby interpreter itself is written in C, isn't it OK to make python/ruby interpreter for iPhone to run the scripts on iphone? Is this poss...

open_id_authentication - "OpenIdAuthentication.store is nil. Using in-memory store." problem

Hi, I am trying to make the open_id_authentication plugin working. Initially was doing it with authlogic but abandoned because it feels like much more hassle the help. The problem is that I am getting OpenIdAuthentication.store is nil. Using in-memory store. warning in the log which prevents from authenticating users correctly. Here i...

How do I start IRB console from a rake task?

I'm trying to write a rake task that will set up an environment mirroring my project. task :environment do require 'rubygems' require 'sequel' # require 'my_projects_special_files' end task :foo => [:environment] do require 'irb' IRB.start end Leads to irb complaining that "foo" doesn't exist (the name of the task) 10:28...