ruby

Using FBML in a ruby sinatra app

Hi, I'm building an application in ruby using the sinatra framework and am having trouble with rendering some fbml elements. I'm currently trying to render an fb:multi-friend-selector so the user can select which friends they want to invite. However, when I write the following in my code: <fb:fbml> <fb:request-form action="/invit...

Is SQLite a good solution to backup postgres on Heroku ?

Hi all ! I'm using the Sequel (Taps) ruby gem for a remote backup of my production database (PostgreSQL). I wonder if storing that backup with SQLite is a good solution. What's your feeling ? Thx ! Edit: Thanks! In fact, my app is hoted on Heroku and I though it was simply impossible to run pg_dump. But -- I found that nice rake...

Rest-Client Installation not working properly...

The following error is displayed in command prompt in Windows 7 C:\Users\rd\Desktop\Training\Problem2\sudoku\sudoku>gem install rest-client WARNING: RubyGems 1.2+ index not found for: http://gems.rubyforge.org/ RubyGems will revert to legacy indexes degrading performance. ERROR: could not find gem rest-client locally or in a ...

is there a way to follow all site redirection methods in ruby?

For my rails app i want to extract the meta-tag contents of website to further processing. but for some sites which redirect to another url , i cant get hold of the final webpage easily. Is there any way in ruby to follow all the site redirections such as http redirect, meta-tag redirect, frame redirect etc. effeciently? Thanks ...

Finding the sum of 2D Arrays in Ruby

Hi, I have an array of two dimensional Arrays. I want to create a new two dimensional array which finds the sum of these values in the 2D arrays. Sum at x,y of new array = Sum at x,y of arr1 + Sum at x,y of arr2 + .... |1,2,4| |1,1,1| |1,1,1| |2,4,6| |1,1,1| |1,1,1| |2,4,6| |1,1,1| |1,1,1| |2,4,6| |1,1,1| |1,1,1| Now adding the...

With Ruby, does "gem install" use "--include-dependencies"... just the doc is a little outdated?

Using Ruby on Rails, if I do a gem help install a part of it says: -y, --include-dependencies Unconditionally install the required dependent gems [...] Defaults: --both --version '>= 0' --rdoc --ri --no-force --no-test --install-dir c:/ruby/lib/ruby/gems/1.8 but if I do a gem install -...

Upgraded activerecord-sqlserver-adapter from 2.2.22 to 2.3.8 and now getting an ODBC error

I have been using MSSQL 2005 with Rails for quite a while now, and decided to bump my gems up on one of my projects and ran into a problem. I moved from 2.2.22 to 2.3.8 (latest as of writing) and all of a sudden I got this: ODBC::Error: S1090 (0) [unixODBC][Driver Manager]Invalid string or buffer length I'm using a DSN connection wit...

Separate validation file for each model in rails.

I have a too many models and want to maitain separate validation and relationship files for each model in rails. Is there any way i can maintain it with rails? Any specific advantage to do it? ...

ruby write newline character to file but do not interpret as a true newline

I am trying to write a ruby string to a file in such a way that any newline characters embedded in the string remain embedded. This is being written out to a file which will then be processed by another tool. An example is below. I want this: 1 [label="this is a\ntest"] \n (second \n is a true newline) I have tried this: string = '1 [l...

Use Delayed::Job to manage multiple job queues

I want to use Delayed::Job (or perhaps a more appropriate job queue to my problem) to dispatch jobs to multiple background daemons. I have several background daemons that carry out different responsibilities. Each one is interested in different jobs in the queue from the Rails app. Is this possible using Delayed::Job, or perhaps there i...

Ruby: how does constant-lookup work in instance_eval/class_eval?

I'm working my way through Pickaxe 1.9, and I'm a bit confused by constant-lookup in instance/class_eval blocks. I'm using 1.9.2. It seems that Ruby handles constant-lookup in *_eval blocks the same way it does method-lookup: look for a definition in receiver.singleton_class (plus mixins); then in receiver.singleton_class.superclass (...

My Ruby Code: How can I improve? (Java to Ruby guy)

Greetings, I get the feeling that I'm using ruby in an ugly way and possibly missing out on tonnes of useful features. I was wondering if anyone could point out a cleaner better way to write my code which is pasted here. The code itself simply scrapes some data from yelp and processes it into a json format. The reason I'm not using has...

Dynamically adding a class to a div in a .erb with Ruby on Rails

I have this div <div class='notice'> And I want the result to be <div class="notice error"> And Is there a way to add a class in my erb? I tried <div class="notice #{new_class}"> But that doesn't escape into ruby code when it renders... and ideas? ...

How to completely uninstall rails 3.0.0.beta3 and all its dependencies?

If I do sudo gem uninstall rails -v 3.0.0.beta3, it uninstalls rails but leaves the beta3 versions of activerecord, actionmailer, etc. How do I completely uninstall rails 3.0.0.beta3 and all its dependencies automatically? I would like a clean slate for the RC and final releases. ...

running the ramaze blog example - an error message

deltrem@deltrem-desktop:~/ramaze web/app/blog$ ruby start.rb I [2010-06-10 14:53:33 $1886] INFO | : activating sequel I [2010-06-10 14:53:33 $1886] INFO | : Installing sequel /usr/local/lib/site_ruby/1.8/rubygems/remote_fetcher.rb:124:in `initialize': Permission denied - /home/deltrem/.gem/ruby/1.8/cache/sequel-3.9.0.gem (Errno::EACCES...

Using Bundler along with preinstalled gems

So I've got thin installed the old fashioned way: gem install thin I put an app on the server and installed all of its required gems via bundler: bundle install But, when I tried to start the app with thin start, it can't find any of the bundler-installed gems since they're not installed in the default gems directory. My question...

How do I pass a conditional expression as a parameter in Ruby?

For example this what I am trying to do, def method_a(condition, params={}, &block) if condition method_b(params, &block) else yield end end and I am trying to call the method like this, method_a(#{@date > Date.today}, {:param1 => 'value1', :param2 => 'value2'}) do end The result is the condition is always eva...

ruby memory leak Gdk::PixbufLoader

So I'm beginning to wonder how leaky the gnome2 libraries for ruby1.8.6 are. #!/usr/bin/env ruby require 'gtk2' while true sleep 0.1 pixbuf = Gdk::PixbufLoader.new pixbuf = nil end this leaks about 16kb/sec according to watch -n 1 ps -o rss -p <process id> This is compounded if you start trying to write a chunk of large chun...

Running Anemone (or other web spider) Client Side

I am looking at building something around anemone but am wary that it will use a lot of my servers bandwidth. Am I right in guessing that anemone spiders from the server it lives on and not the client side that runs it? If that is true, is there a way I can get anemone (or any other ruby spider) to run client side? Thanks ...

what does dash mean in ruby on rails html scriptlet ?

In the web I've seen examples both with <% if @showIt -%> some html content <% end -%> and without <% if @showIt %> some html content <% end %> dash. Both versions work very well. So, what difference does it make? Thanks! ...