ruby

having trouble passing formbuilder using remote_function with nested_attributes_for

Hey all I am having trouble updating a partial that contains a nested_attributes_for form with AJAX. My application needs to load a new section of the form based on the event type chosen in the main form. The fields associated with each type are stored in a database table. At the moment, when I select an event type, the id of the even...

What is a good Ruby on Rails forum that can easily integrated to an existing application?

What is a good, open source RoR 3 forum that can easily integrated to an existing application? Optional features: OpenID support Haml/SCSS templates Support for smilies, YouTube, images, etc I'm probably going to change it alot, and I'm still pretty weak in Ruby, so clean, commented code with good practices would be great. Thanks :)...

How do you write "(A OR B) AND (A OR C)" queries with Mongoid?

I need to write a MongoDB query of the form "A OR B OR (C AND D)" to return some records. We are using Mongoid for data access to our models. I expanded that query to "(A OR B OR C) AND (A OR B OR D)" and was hoping that using Mongoid's Criteria method any_of like this: Model.any_of(A, B, C).any_of(A, B, D) would accomplish what I want...

Short Ruby Case Statement using include? Will Not Work

Hi, I have the following code with a small bug in it, the case statement returns the value "other" even though the first "when" statement evaluates true and should return "boats". I've been been looking at this for ages, must be something small. CATEGORIES = {:boats => [1, 2, 3, 4, 5, 6], :houses => [7, 8, 9, 10], ...

Difference between fields_for syntax

Is there any difference between: <%= event_form.fields_for :client, @client do |client| %> and <%= fields_for @event, :client, @client do |client| %> The parent form looks like this: <% form_for @event do |event_form| %> ...

Intermittent RingNotFound error all processes running locally

(Sorry about duplication of question. I put it in the wrong account at first) Am running a rails application which launches a series of relatively long running scripts using delayed_job and Rinda to farm out the work. At the moment am using a single delayed_job process (rake jobs:work, as am stuck on Windows), a ring server process ...

Ruby regular expressions - speed problem

I want to obtain the information of students in class c79363 ONLY. The following file(users.txt) contains the user id's c79363::7117:dputnam,gliao01,hmccon01,crober06,cpurce01,cdavid03,dlevin01,jsmith88 d79363::7117:dputn,gliao0,hmcc01,crob06,cpur01,cdad03,dlen01,jsmh88 f79363::7117:dpnam,gli01,hmcn01,ober06,crce01,cdav03,dln01,jith8...

Exception using MongoMapper with Ruby: "No file to load mongo_mapper"

I downloaded the mongo_mapper gem and it installed successfully. Now, I am using it in my app and it always throws exception "No file to load mongo_mapper". What is that supposed to mean? require 'mongo_mapper' include mongo UPDATE: After using require 'rubygems' first. My original problem is gone now there is another weird problem: ...

What's happening when Ruby shows something like this: #<Role:0x11157b630>?

I remember coming across this when first watching some Ruby videos, but I can't find it again. When Ruby shows something like this: #<Role:0x11157b630> ,what is going on? I have three roles (admin/staff/client) and I would like to show one of these, not #<Role:0x11157b630>. Any idea how I could do that? Cheers! ...

Rails/Passenger: no such file to load -- bundler

I have an application running an old version of Rails (2.2.2) and Passenger that I got up and running using Ruby Enterprise Edition 1.8.7. However, I soon found there were some incompatibilities between older versions of Rails and Ruby 1.8.7, and decided to downgrade to REE 1.8.6. However, now the application fails to start with a LoadEr...

Why does Ruby have Numeric.new ?

a = Numeric.new # doesn't take an argument I can't imagine a use case for this. Can you? ...

Ruby Get Array From Objects Returned in a Block

In Ruby, on certain occasions (ruby/gosu/texplay) I'v seen code like the following used: image.paint { circle 20, 20 pixel 10, 10 } Would it be possible for me to write a similar function that can be used like so?: my_function { "one" "two" "three" } that would return and array: ["one", "two", "three"] p.s...

Better way to execute ruby file using Python and How to get ruby console output when ruby file is run from python?

Hi, I am building a standalone using python. This standaloone should execute a ruby file. I have read this article - http://www.decalage.info/python/ruby_bridge I have used os.system() which works well. But I have an issue here. If a ruby file has some error, file simply terminates without error. Can you please let me know how to GET r...

"Super from singleton method that is defined to multiple classes is not supported"

I'm trying to use the Steam Condenser library with Ruby 1.9.2 and Rails 3. I have the following code: require "steam/servers/source_server" class HomeController < ApplicationController def index server = SourceServer.new(IPAddr.new("127.0.0.1"), 2000) server.init @m = server.get_players end end but for some reason...

How do I use string.tr to replace double quotes with single ones in Ruby?

How do I use string.tr to replace double quotes with single ones in Ruby? ...

Starting off with Ruby and Ruby on Rails

Hi, I am interested in building web applications using Ruby on Rails. I surfed the Internet and found out that I need to have a prior knowledge of the Ruby language. So can you please suggest some good books, online resources to start off with Ruby first and then Ruby on Rails? Thanks, Rakesh. ...

Which language to use for writing an admin console à la webmin ?

Hi, We have an in house developed web-based admin console that uses a combination of C CGI and Perl scripts to administer our mail server stack. Of late we have been thinking of cleaning up the code (well, replacing most of it), making the implementation more secure, and improving the overall behavior. I don't have much programming kno...

How do I generate a hash from an array

So I'm trying to build a hash from an array. Basically I want to take the unique string values of the array and build a hash with a key. I'm also trying to figure out how to record how many times that unique word happens. #The text from the .txt file: # **Bob and George are great! George and Sam are great. #Bob,...

has many polymorphic images through another polymorphic model

Greets to ruby developers. I'm stuck with ActiveRecord model associations. I illustrate what I want to do by a tables. I have these tables: Products: +----+-----------+ | id | name | +----+-----------+ | 1 | Cellphone | +----+-----------+ Images: +----+-------+--------------+----------------+ | id | url | imageable_id | image...

How to run ruby file in the background using Python and get stderr and stout?

I am developing a Python based GUI. I need to run a ruby file and get its output. I did it successfully using subprocess module. But I need to run the file in the background and I need to get its output as well. Can you please let me know how to achieve this? ...