ruby

How can I get Haml to render the contents of a pre tag correctly?

I read the Haml docs where they talk about the pre tag and "preserving whitespace". According to the docs, pre "preserves whitespace" by default and you need to use the ~ operator to output the contents of the tag to get it to render correctly. Following the recommended practice, I have this: %pre ~ @calendar.main_template The outpu...

Continuing a statement on the next line WITH A COMMENT

If I have a statement in Ruby that I want to continue on the next line, normally I would add a backslash at the end of the line like this: print x \ + y But if I have comments on the line, it doesn't work: print x #show x + y # show y Is there a way around this? (Edit: Squeegy's solution is correct and, actually, I knew you could...

Alignment of edit_line

I am using Shoes 0.r1134, on Mac OS X 10.4 When running the following code, Shoes.app do edit_line("Something") edit_line("Something Else") end the second edit_line control seems to be placed 4 pixels lower than the first one, in such a way that they are not flush with each other. Why is this? ...

What do $undefined and $end refer to in Ruby?

I used a backslash to continue a Ruby statement on the next line. print abc \ + def I added a space after the backslash, because I like to blow things up, and, sure enough, I got an error: unexpected $undefined, expecting $end I assume $undefined is a global variable that means anything the compiler sees that it doesn't recognize -...

Keyword for exclusive or in ruby?

Does Ruby have a plain-English keyword for exclusive or, like they have "and" and "or"? If not, is this because exclusive or doesn't allow evaluation short-cutting? ...

PostgreSQL - tree organization

I'm working on a project wich requires a tree of categories, organized as id, parent, title table. Which are the best ways to retrieve category and its subcategories(and a full tree, if root categories have parent=0) in Postgres? I'm looking for a pure database solution, but if there is a way for Ruby and PHP - it will be great too. The...

What are the things you would like improved in the Ruby language?

I read somewhere that Ruby is the love-child of Smalltalk and LISP, with Miss Perl as the Nanny. I have a lot of respect for Ruby's parents, but I'm not sure I like the influence Miss Perl had on the child. Specifically, I don't like the predefined variables: I need a cheat sheet to know what they mean. You could say "just don't use t...

Is it possible to navigate back in browser with watir?

hi, I'm creating an automated tests that should navigate back a few steps. Is it possible to do so in Watir?? I'm navigating to a resultlist page and want to go back to the start of my test just by clicking back (windows browser). Thnx ...

How can I implement a semantic ontology in Ruby on Rails?

I'm working on a "twitter filter" - more to learn ruby on rails than anything else. The idea is that I use a semantic ontology to lookup a users interests. So if a user says they're interested in "sports" that means flag any tweets that discuss "sports" "golf" "football" and so on. I'd like to be able to expand it to any hierachial of t...

Iconv::IllegalSequence when using www::mechanize

I'm trying to do a little bit of webscraping, but the WWW:Mechanize gem doesn't seem to like the encoding and crashes :-/ The post request results in a 302 redirect (which mechanize follows, so far so good) and the resulting page seems to crash it :-/ I googled quite a bit, but nothing came up so far how to solve this. Any of you got an ...

check_box checked by default in rails 1.2.3

How can I make a check box default to being "checked" when it is initially displayed? I've not found a "Rails" way to do this (that works) so I did it with JavaScript. Is there a proper way to do this in Rails? I'm using Rails 1.2.3. ...

Using the basepath filter to re-write URLs in Webby?

Basepath Filter Rewriting? I'm trying to use the basepath filter in webby to rewrite all of the URLs in my project. The documentation on the basepath filter for Webby is a little bit "light" concerning this, and there just simply isn't enough of it that I can understand how to use it. If I find the solution to this, however I plan to ...

Upgrading Ruby

Is it time to upgrade to Ruby 1.9? ...

Ruby: How to make an HTTP GET with modified headers

What is the best manner to make an HTTP GET request in Ruby with modified headers? I am attempting to get a range of bytes from the end of a log file and have been toying with the following code, but the server is throwing back a response noting that "it is a request that the server could not understand" (the server is Apache) require ...

Programatically moving through a ListView in Qt (Ruby)

I'm making a small file-browser for my own use, in Ruby, and using Qt for the view. The idea is that it'll end up on my TV, where I can use the remote to move up and down and launch files. Everything works fine, until I'm going to move the selection using the remote. I managed to set up a D-Bus service, so I'll just call the methods us...

Programming outlet after typical 9 - 5 day (language switching)

Okay my goal this year is to really gain valuable experience in C#/ASP.NET and JavaScript. But after a typical 9 - 5 day, I find it really hard to come home and fire up visual studio to try out stuff, afterall I've been using it for over 7 hours. Rather when I get home I find myself drawn to the ruby language and droolling over the aweso...

Returning mock objects from factory girl

I am using Mocha and Factory_girl in a JRuby rails application. When I call the factory I would like to return the objects with some mocking already done. Here is a code snippet of what I am trying to do. Factory.define :tweet_feed_with_tweets, :parent => :tweet_feed do |t| t.expects(:pull_tweets).returns([Factory.build(:status),Fac...

What's the main Ruby language discussion board (not including S.O.)?

I'm talking about a forum/message board where people just talk about the Ruby language - quite aside from its use in terms of Ruby-on-Rails. It seems most languages have favorite forums outside of Stackoverflow - just wondering what that would be for Ruby. I've had a look on Google but what comes up seems to be mostly personal blogs ab...

Using Ruby Enterprise Edition, gems are not installed where I would expect

I have just installed Ruby Enterprise Edition and am installing some gems for it. Stock Ruby 1.8.6 is also installed on the server. I have added /opt/ruby-enterprise-1.8.6-20090201/bin to my PATH a head of /usr/bin where ruby and gem live. which gem confirms this: /opt/ruby-enterprise-1.8.6-20090201/bin/gem However, when I install g...

Favorite ruby trick?

Hello, I'm interested in hearing what your favorite ruby trick is. I'm a big fan of using inject in new and unique ways. You? ...