ruby

Adding an action to an existing controller (Ruby on Rails)

I am new to Ruby on Rails, I have completed the Blog Tutorial. I am now trying to add an additional action to the controller, called 'start'. def start end I have added a view page "app/views/posts/start.html.erb" containing nothing but simple html. When I go to /posts/start i get the following error. ActiveRecord::RecordNotFound i...

How to reduce the size of an sqlite3 database for iphone?

edit: many thanks for all the answers. Here are the results after applying the optimisations so far: Switching to sorting the characters and run length encoding - new DB size 42M Dropping the indexes on the booleans - new DB size 33M The really nice part is this hasn't required any changes in the iphone code I have an iphone applica...

Anyone Try Running Rails 2.2 (or Edge) under Ruby 1.9.1 RC1

Ruby 1.9.1 RC1 was released today so I quickly moved to install it (a test version of course using a suffix of 19). I install Rails and Rack for the 1.9 RubyGems and then create a new Rails site using edge... when I execute: ruby19 ./script/server I watch as the processor usage goes up to 99.8 and the terminal just sits there. Trying ...

How to elegantly compute the anagram signature of a word in ruby?

Arising out of this question, I'm looking for an elegant (ruby) way to compute the word signature suggested in this answer. The idea suggested is to sort the letters in the word, and also run length encode repeated letters. So, for example "mississippi" first becomes "iiiimppssss", and then could be further shortened by encoding as "4im...

Beginner Programmer - Which direction

Hi, I am pretty much a classified beginner programmer, messing in a few languages. I know basic C# from a principle and paradigm point of view. My question is where do go from here? Should I try out other languages, should I delve deeper into C#, learn C/C++/Ruby/Python, should I learn more about programming in general (OOP and Function...

Using Shoes and download over https gives ssl errors

In a shoes application am trying to download stuff from some internal websites. I get this error Error in /tmp/selfgz14214/ruby/lib/net/protocol.rb line 66 undefined method 'closed?' for #<OpenSSL::SSL::SSLSocket:0xb6af94f0> I got the above error for this code. This give the above error if used from Shoes. require 'net/http' require ...

Camellia Ruby Computer Vision Library on OS X

Has anyone had any luck getting the Camellia computer vision library to install on OS X? I've been banging my head against a wall trying to get it to install. There is only one reference I can find online and it is a bit dated. I've followed the instructions to the T with no luck. I'm hoping one of your brilliant folks on SO can help a ...

Learning Ruby: recommended blogs to read?

I'm about to start learning Ruby and would like a bit of reading material to help me into it. I'm looking for your top 5 blogs, news and any (active) bulletin boards (I can handle newsgroups fine, but I prefer reading in a BB) on Ruby. Thanks, ...

On Ubuntu does Shoes require Ruby1.8 or Ruby1.9 ??

I have only installed Ruby1.9 on my machine. Have some kind of problems with the programs I am trying to write using Shoes. Am wondering if this is a version issue. I am trying to do some stuff over ssl. ...

How do I move file with Ruby

I want to move a file with ruby. How do I do that? ...

Good Ruby/Rails testing tutorial?

Can someone recommend a good, up-to-date tutorial for a complete beginner on one of the major testing frameworks for Ruby, such as Rspec or Shoulda? I'd like to find something that doesn't assume any knowledge about the framework or about testing in general. For example, if the tutorial explained the distinction between TDD and BDD, that...

Ruby: More flexibility than Java/C#?

Is is that I'm a newbie learning Ruby, or does it really have more ways to write (the same) things than Java/C#? Also, if it is more flexible than Java, are there any linguistic features of Ruby that are generally not used to avoid confusion? Examples might be parallel assignment and all the different ways to write Strings, perhaps? No...

Stupefied by RSpec

I'm sorry, but this is beginning to feel like kicking myself in the head. I'm completely baffled by RSpec. Have watched video after video, read tutorial after tutorial, and still I'm just stuck on square one. === here is what I'm working with http://github.com/fudgestudios/bort/tree/master === Errors F 1) NoMethodError in 'biddin...

How do I write raw printer code to a windows printer share from ruby?

Using java, minus the exception handling, it is as simple as FileOutputStream ostream = new FileOutputStream("\\\\host\\share"); PrintStream printStream = new PrintStream(ostream); printStream.print("HELLO PRINTER"); printStream.close(); ostream.close(); ...

Please advise on Ruby vs Python (for someone who likes LISP a lot)

Hi, I am a C++ developer, slowly getting into web development. I like LISP a lot but don't like AllegroCL and web-frameworks available for LISP. Which one is closer to LISP: Python or Ruby? I am looking for more freedom and ability to do cool hacks on language level. I don't consider tabs as a crime against nature. I can't seem to be a...

What is your convention for specifying complex SQL queries in Rails?

I am fairly new to Rails and I was curious as to some of the conventions experts are using when they need to construct a very complex SQL query that contains many conditions. Specifically, keeping the code readable and maintainable. There are a couple of ways I can think of: Single line, in the call to find(): @pitchers = Pitcher.fin...

Using rake with a non-ruby project

A workmate floated the idea of using rake as a build system for a non-ruby project. Is it possible to extend rake to compliment other languages where the autoconf toolset would usually be used? ...

Language in a Sandbox in Rails

I've found that there WAS a sandbox gem (created by the guys that made try ruby in your browser but it was compatible only with Ruby 1.8. Another problem is that I cannot find it anymore (it seems they stop serving the gem from the servers...). So, is there any secure way of running ruby in a sandbox (so you can run it from your browser...

Why does Ruby have Rails while Python has no central framework?

This is a(n) historical question, not a comparison-between-languages question: This article from 2005 talks about the lack of a single, central framework for Python. For Ruby, this framework is clearly Rails. Why, historically speaking, did this happen for Ruby but not for Python? (or did it happen, and that framework is Django?) Also,...

Ruby - Immutable Objects

I've got a highly multithreaded app written in Ruby that shares a few instance variables. Writes to these variables are rare (1%) while reads are very common (99%). What is the best way (either in your opinion or in the idiomatic Ruby fashion) to ensure that these threads always see the most up-to-date values involved? Here's some ideas ...