ruby

How to update ruby-interpreters with RVM?

I installed RVM with a few version of ruby-interpreters some time ago. How I can to update it, because new versions are already realeased? I found only one way: rvm install 1.9.2-rc1 && rvm remove 1.9.2-preview1, but my gems are lost... Can I update branches time to time? I haven`t found any tips in documentation. ...

Which is the best 0auth gem for a rails app?

Hi there, I'm going to add Oauth autenthication to my rails web app. Since I don't want to reinvent the wheel, have you got some ruby gem to suggest to add this kind of feature? TIA Paolo ...

How to paginate two tables in one view

Hello,I want to ask if i can use will_paginate plugin two times on one page? For example i have table with male users and table with female users on one page or in one view and I need paginate both tables. My question is what is the usual solution of this problem? ...

Ruby passing different attribute arguments to same function

Hello, I have a job model which has many attributes. I would like to use graphics to display the sum of some of these attributes. For that, I am using the following code in the javascript portion of the view which produces the graph: <% for job in @daily_jobs %> ['<%= job.day %>',<%= job.walltime %>], <% end %> This returns ...

List methods only in a module?

I wonder how one can list all methods in a module, but not including inherited methods. eg. module Software def exit puts "exited" end end puts Software.methods Will list not only exit, but all inherited methods. Is is possible to just list exit? Thanks ...

PHP equivalent for Ruby's or-equals (foo ||=bar)?

In PHP I often write lines like isset($foo)? NULL : $foo = 'bar' In ruby there is a brilliant shortcut for that, called or equals foo ||= 'bar' Does PHP have such an operator, shortcut or method call? I cannot find one, but I might have missed it. ...

Require a module file and interact with its module?

In a folder I have random module files. eg. "user.rb" that contains "module User", "customer.rb" that contains "module Customer" and so on. I want to require all files and print out all module methods. Here is my current code: @@data_module_methods = [] # iterate through all files in the data folder Dir[File.join(APP_ROOT, "da...

Google Apps Authentication for a Rails App

Hi, I'm currently using Authlogic to handle all user accounts, but our company has switched over to Google apps and I would much rather use that same authentication for all users. My question is - how? I know I'll need the ruby-openid gem but I have yet to integrate authentication with a 3rd party. Any recent examples or tutorials out...

Best way to generate javascript code in ruby (RoR)

Hi, I have seen some rails plugins which generate javascript code dynamically using ruby. 1. %Q ( mixed block of javascript and ruby ) 2. <<-CODE some mixed ruby and javascript code CODE Being a java developer I don't understand what those strange looking syntax mean ? Is one way better than the other ? can anyone point me to...

Parser in Ruby: dealing with sticky comments and quotes

I am trying to make a recursive-descent parser in Ruby for a grammar, which is defined by the following rules Input consists of white-space separated Cards starting with a Stop-word, where white-space is regex /[ \n\t]+/ Card may consist of Keywords or/and Values also separated by white-space, which have card-specific order/pattern Al...

How do I allow a user to select zero options from a multiple selection box in rails?

I have a settings model with a column options, and set it to serialize with serialize :options. In my view, I have a multiple selection box, using select("settings", "options", ['option1','option2','option3'], {}, :multiple => true) which works fine so long as the user selects at least one option. However, if they don't select any opti...

Need help understanding some Ruby code from

I was looking through some code in a string escape library the other day and I came across some code that looks like this: class StringWrapper class << self alias new_no_dup new def new(str) new_no_dup(str.dup) end end def initialize(str) @str = str end ... end Can anyone explain exactly what is goi...

Compare arrays and remove duplicates, in Ruby?

What would be the easiest way to compare multiple arrays, and remove duplicates? So (arrays inside arrays in this case)... a = [[2, 1], [3, 3], [7, 2], [5, 6]] b = [[2, 1], [6, 7], [9, 9], [4, 3]] c = [[2, 1], [1, 1], [2, 2], [9, 9]] d = [[2, 1], [9, 9], [2, 2], [3, 1]] ...would come out (with priority given to array a, the...

convert a JPEG to SWF in Ruby?

Are there any gems / libraries which can be used with Ruby to convert a JPEG into a SWF file with a specific duration? I need to take a list of JPEGs and convert them into a SWF slideshow. ...

Rails ActiveRecord date parsing for i18n (specifically european date formats).

I'm working on a rails project for an Australian website. As a result, they want to be able to enter date formats in the more european-standard of 'dd/mm/yyyy' rather than the US-centric 'mm/dd/yyyy'. I have an ActiveRecord model with a Date field. I'm using jQuery's datepicker to provide the date select on a text field, and have it s...

A great YAML library for ruby?

Could anyone suggest a well-documented and well known YAML library for ruby? A book I read used one like this: YAML.load_file(conf.rc).each do |k,v| conf.send("#{k}=", v) end Anyone know which library is used? Thanks ...

Couldn't find 'devise_install' generator - Rails 2.3.8, Devise 1.0.8

I'm trying to get Devise up and running with a freshly generated Rails 2.3.8 app. This is the error I'm running into: devise > script/generate devise_install Couldn't find 'devise_install' generator I do have the Devise and Warden gems specified in my config file: config.gem 'warden', :version => '0.10.7' config.gem 'devise', :vers...

What is the purpose of RakeFile in the application root directory

I am using Ruby on Rails and I see a 'Rakefile' in my application's root directory. What is its purpose and when will it get executed? ...

ming swf library how to install in Ubuntu ?

Can someone please explain how to install ming in an Ubuntu 10.0.4 (Lucid) environment? I've been hearing really amazing things about this package, but I can't get it to install correctly. ...

Possible to annotate just one model in Ruby on Rails?

Working with a large code base and I'm hesitant to run annotate on all models. Is it possible to use the Rails annotate plugin to just annotate one model at a time? ...