ruby

Building a website - best practice and architecture with Ruby.

Dear all Any pointers on best practice when it comes to architecure on the web. I've just learnt a bit of Ruby and wish to use it to build websites. I'm in no hurry, I want to learn the best way not a quick'n'dirty way as this is a hobby. How do i get data from my mySql db to my front end? I know a bit of xhtml / css but how do I now j...

Ruby Web Services

Hi I'm contemplating creating a web application using a Ruby on Rails/MySQL stack and I am wondering what capabilities are available around web services and SOAP. Is there a capability within the framework or does it require an extension and if so what? ...

Why can I not concatenate two strings and assign them to a symbol?

. . . as in this example: helloworld.rb:1: syntax error, unexpected '=', expecting $end :helloworld = "hello ".concat("world") I thought if I use concat I'm modifying the string "hello " and adding "world" to it and then ultimately assigning the resulting string - "hello world" - to the :helloworld symbol on the left side of the equal...

Parsing an HTML table using Hpricot (Ruby)

I am trying to parse an HTML table using Hpricot but am stuck, not able to select a table element from the page which has a specified id. Here is my ruby code:- require 'rubygems' require 'mechanize' require 'hpricot' agent = WWW::Mechanize.new page = agent.get('http://www.indiapost.gov.in/pin/pinsearch.aspx') form = page.forms.find...

What are the most active Ruby forums/blogs on the web?

I have just spent 2 days with Ruby, and my observation in last two days is that it is very difficult (as compared to say .NET/Java) to find an active forum/blogs which are helpful for Ruby (or maybe I don't know them since I am new). Which are the most common forums/blogs developers visit when they need help with Ruby (other than Stack ...

Simple recursion problem

I'm taking my first steps into recursion and dynamic programming and have a question about forming subproblems to model the recursion. Problem: How many different ways are there to flip a fair coin 5 times and not have three or more heads in a row? If some could put up some heavily commented code (Ruby preferred but not esse...

What is the order of operations with this concatenation?

x = "hello" " world".to_sym puts x.class This works and allows me to concatenate the two strings into a symbol, producing the output: Symbol But if I change it slightly to use a + instead of a space separating the hello and world strings, I get an error: x = "hello" + " world".to_sym puts x.class This produces the following e...

Can someone explain Gtk2 packing?

I need to use Gtk2 for a project. I will be using python/ruby for it. The problem is that packing seems kind of mystical to me. I tried using a VBox so that I could have the following widgets in my window ( in the following order ): menubar toolbar text view/editor control I've managed to "guess" my way with pack_start and get the la...

Ruby relative_path_from call on Windows

I'm running into an issue with the portion of the Rails generation script that searches the plugin path for appropriately named files to find generators. On one of my systems, I have Ruby installed in c:\dev\ruby and have my project directory at d:\local\projects The Ruby Pathname#relative_path_from method (which is called by the Rails ...

Screen scrape web page that displays data page wise using Mechanize

I am trying to screen scrape a web page (using Mechanize) which displays the records in a grid page wise. I am able to read the values displayed in the first page but now need to navigate to the next page to read appropriate values. <tr> <td><span>1</span></td> <td><a href="javascript:__doPostBack('gvw_offices','Page$2')">2</a><...

Routing in Rails

Hi everyone, I'm designing a minimalistic wiki in RoR. Basically a project have many pages. My routing file looks like this: map.root :controller => "projects" map.resources :projects, :has_many => :pages map.connect ':id', :controller => 'projects', :action => 'show' map.connect ':project_id/:id', :controller => 'pages', :action => 's...

Pygame equivalent for Ruby?

I was wondering if anyone knew of a PyGame equivalent for Ruby. I've seen Ruby/SDL and I'm looking for something a little more geared towards games. ...

Why does the absence of the assignment operator permit me to modify a Ruby constant with no compiler warning?

In the following two examples I do the same thing, creating a constant String and using the concat method to modify it. Because it's a constant, I expect a compiler warning but only receive one in the second example when I use the assignment operator. Why is this? X = "hello" X.concat(" world") puts X # no warning X = "hello" X = X.con...

Does anybody know a real life example of IronRuby usage

Although I'm not a .NET developer I always get excited about the work DLR team is doing at Microsoft. I watched a couple of videos from various Ruby conferences where John Lam showed the progress of IronRuby and Dynamic Language Runtime in general. The latest video I saw is from Ruby conf: http://rubyconf2008.confreaks.com/ironruby.html ...

Can I jump back to the beginning of a method using 'redo' in Ruby?

In the Poignant Guide this example of the redo keyword is given: class LotteryTicket def self.new_random new(rand(25) + 1, rand(25) + 1, rand(25) + 1) rescue ArgumentError redo end end It's supposed to keep calling new until all three random numbers are unique. But after I typed this code in and ran it a few times, I got...

will shoes support GTK on windows? can we use all ruby-gnome2 APIs in shoes?

I know neither is true for now, but I really want these to be true. I heard that ruby-gnome2 and shoes are the top most used desktop libraries for ruby. since shoes and gtk depends on some common things, and shoes give a higher abstraction for UI, why not go a step further to merge them? make shoes totally on top of GTK. I respect diffe...

How do I get shoes executable into my path?

I'm getting started with shoes and the nks docs tell me two write a script and then launch it like this: > shoes myapp.rb the shoes executable is in the Shoes.app I installed. Thus, shoes is not in my path so I can't do this. Tried symlinking shoes into /usr/local/bin but I get this error when I try to start it. > shoes myapp.rb FSP...

The operation could not be completed. No such interface supported (Ruby In Steel)

I installed Ruby In Steel Trial Edition for Visual Studio 2008 and when i try to save a an IronRuby Project, it keep warning "The operation could not be completed. No such interface supported". I cannot save the project but only run it. Help me plz!, I'm noob with Ruby and Ruby In Steel. ...

Am I understanding the sequence of events in this Ruby grep example?

I'm trying to understand how grep works in this example. The code works but I'm not 100% sure in what sequence the events take place or whether I'm correctly understanding what's being returned when and where. cars = [:Ford, :Toyota, :Audi, :Honda] ucased_cars = cars.collect do |c| c.to_s end .grep(/^Ford/) do |car| puts car.upcase ...

Rails ActiveRecord: Inserting text containing unprintable/weird characters

I am inserting some text from scraped web into my database. some of the fields in the string have unprintable/weird characters. For example, if text is "C__O__?__P__L__E__T__E", then the text in the database is stored only as "C__O__" I know about h(), strip_tags()... sanitize, ... etc etc. But I do not want to sanitize this SQL. Th...