ruby

rspec falling apart... possibly a ubuntu stability issue .. ruby corrupted

hey all ive got a really interesting set of problems im learning some new development techniques ... ruby on rails :D so ive run this code numerous times: spec spec/ as you can see from the code: these are back-to-back runs via terminal of "spec spec/" http://pastie.org/1020719 returning different results... i was told that softw...

Ruby works well with Unicode character in Filenames on Mac OS X and on Linux, but why to make it work on Windows, it took at least 2 years?

Ruby works well with Unicode character in File Path and Filenames on Mac OS X and on Linux, but why to make it work on Windows, it took more than 2 years? I was just looking at Google Code Jam. People are solving non-trivial problems within a few hours. At work, I can imagine solving a filename or path issue having unicode characters ...

Block comments in html.erb templates in rails

How do you comment out html mixed with ruby code? some text <% ... %> more text <%= ... %> something else <% ... %> In jsp it's real simple: <%-- ... --%>, but I'm unable to find any concise option in rails. Simple html comments <!-- ... --> do not work: ruby code is still executed and yells errors. There's an option to use if fal...

String operation...

What's simplest way to turn the string "YingYang" into "Ying/Yang"? ...

Variable assignment...

variables a, b, c and d all need to be set to 'foo'. Is there a way to accomplish this in one swooping assignment? Like: a, b, c, d = 'foo' ...

Git library for Ruby or Python?

I'm looking for a Ruby or Python implementation of the Git client that can be used to update and commit changes in a local repository. I prefer if the library does not use shell commands at all but keeps everything in "pure code". Are there any? Thank you in advance. ...

What is the best Diff library in Ruby?

I've looked at diff-lcs ( http://raa.ruby-lang.org/project/diff-lcs ) but it's poorly documented, and appears to be unmaintained. Are there any good, actively maintained ruby gems for diffing text or html files? ...

Very simple sexp parser

For an assignment, we had to implement something like a very basic sexp parser, such that for input like: "((a b) ((c d) e) f)" It would return: [["a", "b"], [["c", "d"], "e"], "f"] Since this was part of a larger assignment, the parser is only given valid input (matching parens &c). I came up with the following solution in Ruby: ...

Ruby On Rails: access a variable from a form, without saving it to database

Dear all, I have 3 pages: [Page 1] Index [Page 2] User enter value in a form. [Page 3] Do calculation on the value entered and output it on this page. I as wondering how do i do this? I do not want to save the data in any database. Thank you =) *Added info 20100628 based on feedback. Thank you! * for PHP, I could user $_GET and %...

OS X gem execution environment

NOTE: user377519 (answer below) pointed me in the right direction. I've posted the 'fix' at the bottom of the questions, in case you found this and need more than a 'pointer' I can't figure out why the second call to "gem env" doesn't have the same environment as the first? Any pointers? This is driving me crazy!!!! $ which gem /usr...

Foreign key (class_id) not populating in belongs_to association

Hello, I'm new to rails and building a small test app on rails3 (beta4). I am using Authlogic to manage user sessions (setup in a standard fashion as per this tutorial) I have scaffolded and setup a card model (a post basically), and set up the basic active record associations for a belongs_to and has_many relationship user.rb has_m...

string to int currency formating

When there is a string value such as 3.76 how can this be converted into a int cent value in this case 376. I was thinking of using sprintf to remove the dot then convert to int but can't work out the syntax. How would I do this and is it the best way ...

Rails: Image Upload with Tableless Model

Here is the scenario, i would like the user to input all the data and all and use em to populate a result. I won't need to store them in a database since i will just be showing them a result page. I did http://railscasts.com/episodes/219-active-model and made my model tableless. But now i have a problem when i wanna receive image uploa...

iPhone video geo-data metadata

Is there a command line tool or ruby gem that can extract the geo-data from videos recorded on an iPhone? ...

Rails Validation Error

Hi... While trying to add an error message using add_to_base, I am getting an undefined method 'errors' message. I am defining it in my model. Am I supposed to include any other file in order to access the errors variable. Model File - I am defining it inside a method self.errors.add_to_base("Invalid Name") Error Message undefined ...

Validating string using ruby Reg Expressions?

Hi how can i validate that the date and time in the following string is in the right format i.e year, month, day and then the time(4 digits, 2 digits, 2 digits and then the time) "Event (No 3) 0007141706 at 2010/04/27 11:48 ( Pacific )" thanks ...

Authlogic and conditional validation

Hi, is there any possibility to perform conditional validation in authlogic's model User, that uses validation inside acts_as_authentic block depending on some conditions? I'm trying to implement multistep registration form, described in Ryan Bates's railscast 217 with authlogic. ...

Rails: Facebox link if condition is satisfied

I want to display a facebox link when I click on a element when a particular condition is satisfied. I do not want the user to click if the condition is not satisfied. I am doing something like this to achieve it which is pretty ugly <% if x == 5 %> <a id="something" href="http://www.some_weird_link.com" rel="facebox"> <% end %> <...

class in ruby(declaration of class in ruby)

Is this statement enough in Ruby to create a class? demo = Amiy.new Will it create a class named Amiy in Ruby? ...

Looking for a job queue that can run jobs at a specified time

Hi, I'm looking for a job queue that has the following features: Can specify a specific future time for a job to be run Failures are recorded The ability to delete specific jobs from the queue (can live without this one but would be nice) Not MySQL based Works well with Rails So far I've looked at a few such as starling and sparrow ...