ruby

ActiveScaffold and associations

My model "combobox" has_many "comboboxselects", and "comboboxselects" belongs_to "combobox". Activescaffold of "comboboxes" displays data in comboboxselects-column like "#<Comboboxselect:0x472d25c>". How to make display the "answer" column from table "comboxselects"? Models: class Combobox < ActiveRecord::Base has_many :comboboxselect...

Simple Captcha - How to test ?

I am using Simple Captcha plugin for generating the captcha. Does anybody know how do I modify rails tests to handle this? ...

Create an ActiveRecord database table with no :id column?

Is it possible for me to create and use a database table that contains no :id column in ActiveRecord, Ruby on Rails. I don't merely want to ignore the id column, but I wish it to be absolutely non-existent. Table Example :key_column :value_column 0cc175b9c0f1b6a831c399e269772661 0cc175b9c0f1b6a831c399e26977...

What are some good role authorization solutions used with Authlogic?

I am looking for a good role based authorization solution to use alongside Authlogic. Anyone have any good suggestions? Please list some pros and cons from your experience if possible please. ...

Converting Time/DataTime/Data into java.util.Calendar?

Is it possible in easy way to convert JRuby Time/DataTime/Data into java.util.Calendar including the timezone? On #jruby I was given such code cal.set_time_in_millis(time.to_i) but I lost information about timezone in betwean. So the more specific question is how to convert the timezone but I prefered to ask more broad questin in case t...

Testing login in a page.

I have to access some pages at work and then log into them to report any problems. I was thinking of writing a program to do this. First, I have to be able to access the pages, then I have to locate the login form and send the info. Currently, I plan on printing true/false for each test (accessibility and login) and then filling the for...

How to trap signal on ruby running on windows

How to trap signal on ruby running on windows? I want to send signal/message from c++ application to ruby script ...

Ruby: client-side or server-side?

Is Ruby client- or server-side? ...

Using a string as Function name

Hi I have to made a generic function which is used for the purpose of calling many other functions depending upon the accesses im getting. For Ex: def func1 @access = ['public','private','protected'] for acc in @access @temp = "get_"+acc[1]+"_data" end end def get_public_data end def get_private_data end def get_pro...

Replace umlaute (äüö) for SEO link in rails - best way

Hi, I'm using the permalink_fu plugin to create permalinks from titles. My problem is: If the title contains german characters, they are just replaced with '_'. What I need is something that replaces ä with ae ü with ue ö with oe I fount String.tr but the problem here is that it replaces 1 character with 1 replacement, so it would wor...

What's wrong with this regex to validate URLs in Ruby?

I am passing an array of URLs to validate. The function is below. It works when I pass just one URL, but not more than one. the regular expression seems to be correct. Where am I going wrong? def check_urls (list) regexp =/(^$)|(^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$)/ix list.eac...

Redmine plugin: Uninitialized constant I18n

We just installed Redmine Charts (http://github.com/mszczytowski/redmine_charts/tree/master) and the associated OpenFlashChart plugin but when we start the Ruby server, we get the error below. Our steps were to: Download the tar file for charts Untar into $REDMINE_ROOT/plugins dir $REDMINE_ROOT/script/plugin install http://svn.pullmonk...

is it possible to find out if a ruby socket is in state ESTABLISHED or CLOSE_WAIT without actually sending or reading data?

s = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0) s.connect(Socket.pack_sockaddr_in('port', 'hostname')) ssl = OpenSSL::SSL::SSLSocket.new(s, sslcert) ssl.connect from here on i would like to check in a thread if the ssl connection and the underlying socket is still ESTABLISHED or if it went into CLOSE_WAIT after the default of ...

SEO urls in rails: .html ending vs. none. What's best?

Hi, I'm thinking about a good SEO Url strategy for a blog application. I'm not sure - and maybe it's just the same - but what is better? With or without .html /blog/entry_permalink_name.hml VS /blog/entry_permalink_name What do you think? ...

Is there a radix function in ruby?

While reading through another question here, on creating a URL shortening service, it was suggested to take the ID of the row, and then convert it to base 62 (0 to 9, a to z, and A to Z). Is there a standard function to accomplish this in Ruby? Edit: Not sure if I was clear enough. Something like this: 123456.radix(62) should give th...

Storing Application Text: Inline vs. Separate File

I'm working on a Merb application using Haml as the templating language. As haml encourages moving logic out of the view and into helpers, I soon started thinking about removing the copy / text from the templates themselves. In the past I have either just left the text inline within the templates, or moved it into separate yaml files sep...

How does Smalltalk deal with monkeypatching ?

I'm a Ruby coder. For me, monkeypatching is to change, at runtime, classes or modules methods in an external project. What I'm interested in, is what mechanism you have in place that will protect you from some of the abuses of that nice feature. Follows, some scenarios that I have encountered, where monkeypatching has bitten me. While I...

Functional testing redirection in a Rails controller

I'm trying to make it so when a model is created via created action it redirects to its show action. That part works fine, but I can't get my functional test to behave. These tests have been modified from what the scaffold provides. def setup @thing = Factory(:thing) assert(@thing.id, "Virtual fixture not valid.") end def...

What's the best way in Ruby to average sets in an array?

Given the following simple data set, what is the best way to average the values for the sets 0 25 53 and 80. [["0", "148.5"], ["0", "146.5"], ["0", "148.6"], ["0", "202.3"], ["25", "145.7"], ["25", "145.5"], ["25", "147.4"], ["25", "147.3"], ["53", "150.4"], ["53", "147.6"], ["53", "147.8"], ["53", "21...

How to build a top-like UI in Ruby

I want to build an application with a text based UI that is similar to the Linux command 'top', in Ruby. What toolkits and/or techniques can I use to build the UI? In particular I want an area of the console window that is constantly updating, and the ability to press keys to manipulate the display. ...