ruby

Best way to convert a Ruby string range to a Range object

I have some Ruby code which takes dates on the command line in the format: -d 20080101,20080201..20080229,20080301 Which means I want to run for all dates between 20080201 and 20080229 (inclusive) and the other dates present in the list. Given I can get the string 20080201..20080229 what is the best way to convert this to an instance ...

Plain text passwords in Ruby on Rails using Restful_Authentication

If i use restful_authentication in my ruby on rails app are passwords transfered between the broswer and the server in paintext? And if so how worried should I be about it? ...

Automatic code quality tool for Ruby?

One thing I really miss about Java is the tool support. FindBugs, Checkstyle and PMD made for a holy trinity of code quality metrics and automatic bug checking. Is there anything that will check for simple bugs and / or style violations of Ruby code? Bonus points if I can adapt it for frameworks such as Rails so that Rails idioms ar...

Learning Ruby on Rails

As it stands now I'm a Java and C# developer, but the more and more I look at Ruby on Rails, the more I really want to learn it. What have you found to be the best route to learn RoR? Would it be easier to develop on Windows, or should I just run a virtual machine with linux? Is there an ide that can match the robustness of Visual Stu...

Options for distribution of an offline Ruby on Rails application

I am developing an application in using Ruby on Rails, mostly as an excuse to learn the language. This is not intended to be a web-based application - and perhaps I have chosen the wrong language, but... My understanding is, that in order to run an instance of this application on somebody else's computer, they would need to install rub...

Does ruby have real multithreading?

I know about the "cooperative" threading of ruby using green threads. How can I create real "OS-level" threads in my application in order to make use of multiple cpu cores for processing? ...

Directory layout for pure Ruby project

Hi! I'm starting to learn ruby. I'm also a day-to-day C++ dev. For C++ projects I usually go with following dir structure / -/bin <- built binaries -/build <- build time temporary object (eg. .obj, cmake intermediates) -/doc <- manuals and/or Doxygen docs -/src --/module-1 --/module-2 -- non module specific sources, like main.cp...

How do I send mail from a Ruby program ?

I want to send email from a Ruby application. Is there a call in the core language to do this or is there a library I should use ? What's the best way to do this ? ...

Ruby - Get a Variable's Name

I'm not entirely sure if this is possible in Ruby, but hopefully there's an easy way to do this. I want to declare a variable and later find out the name of the variable. That is, for this simple snippet: foo = ["goo", "baz"] How can I get the name of the array (here, "foo") back? If it is indeed possible, does this work on any variab...

A good Ruby book (that resembles Dive into Python)

Anyone came across something like Dive Into Python for Ruby? Something that: Gets the language knowledge across by examples of real code that does something useful not just trivial one-liners Is ment for experienced programmers, not newbies (i.e. does not explain obvious stuff like object-orientation and what is a instance vs. class va...

How do you change the displayed order of ActiveScaffold "actions"?

I am using ActiveScaffold in a Ruby on Rails app, and have replaced the default "actions" text in the table (ie. "edit", "delete", "show") with icons using CSS. I have also added a couple of custom actions with action_link.add ("move" and "copy"). For clarity, I would like to have the icons displayed in a different order than they are. ...

How can I display simple tooltips on icons in html?

I am using ActiveScaffold in a Ruby on Rails app, and to save space in the table I have replaced the default "actions" text in the table (ie. "edit", "delete", "show") with icons using CSS. I have also added a couple of custom actions with action_link.add ("move" and "copy"). For clarity, I would like to have a tooltip pop up with the r...

How to setup a RAILS integration test for XML mehtods

Given a controller method like: def show @model = Model.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => model } end end What's the best way to write an integration test that asserts that the return has the expected XML? ...

Best Editor or IDE for Ruby?

I've heard so much about Textmate - The Missing Editor for Mac and that it is the best one for Ruby. What is your choice? And what is the best Ruby editor on Windows? E? ...

How to create multiple records at once with ActiveScaffold in ROR

I am wanting to use ActiveScaffold to create assignment records for several students in a single step. The records will all contain identical data, with the exception of the student_id. I was able to override the default form and replace the dropdown box for selecting the student name with a multi-select box - which is what I want. Th...

What is the easiest way to duplicate an activerecord record?

I want to make a copy of an activerecord record, changing a single field in the process (in addition to the id). What is the simplest way to accomplish this? I realize I could create a new record, and then iterate over each of the fields copying the data field-by-field - but I figured there must be an easier way to do this... such as:...

What's the best way to write JavaScript/Ruby applications on Windows Mobile device?

I recently bought a Windows Mobile device and since I'm a developer I want to use it as a development platform. Yes, it's not supposed to be used like that but it's always with me and my laptop isn't. I know cke is a good editor for code but how can I run JavaScript/Ruby code without too much of a headache? I probably could write a web ...

Rails Model, View, Controller, and Helper: what goes where?

In Ruby on Rails Development (or MVC in general), what quick rule should I follow as to where to put logic. Please answer in the affirmative - With Do put this here, rather than Don't put that there. ...

How to determine the value of a controller variable during execution in Ruby on Rails?

What is the best way for me to determine a controller variable's value during execution? For example, is there a way I can insert a break in the code, and cause the value of the variable to be output to the screen (or the log)? ...

Best Practices for Architecting Large Systems in a Dynamic Language

From my experiences building non-trivial applications in Java and C#, I know that using good modular design based on known patterns and "coding to interfaces" are keys to success. What are the architecture best practices when building large systems in a dynamic language like python or ruby? ...