ruby

Thinking Sphinx not indexing associated data to model searched by.

In my Product.rb define_index do indexes :name, :sortable => true indexes brand has :id, kosher_id, gluten_free_id, lactose_free_id has stores(:id), :as => 'store_ids' has locations(:id), :as => 'location_ids' has categories(:id), :as => 'category_ids' has kosher(:passover), :as => 'kosher_passover' end ...

How to read values off a Windows app?

I need to pull values off a Windows application at regular intervals. Since the values do not appear in a field, I am not able to use Win32 API calls to get them (I figured that out using WinID, a tool that will display information on windows and controls and stuff). I tried using the Office MODI OLE object and the Tesseract CLI tool, b...

Watir Excel call not working on virtual machine

I have a watir test that downloads some information from a web app to an Excel file, and I then open the file to confirm the contents. On my dev box everything works fine, but the scheduled automation runs (via Hudson) always fail attempting to open the Excel file. I have checked that the correct version of AutoITX3.dll is registered o...

Create new records on before_save.

While creating new records. I need to create more records for the same model. Example :: class XYZ < ActiveRecord def before_save # At this point object is already initialized .. # And it's containing values. # At this point i want to create 10 more records for the same class. # something like this XYZ.new(:att1 => valu...

How to search an array in Ruby?

Say I have an array of strings arr = ['sandra', 'sam', 'sabrina', 'scott', 'mark', 'melvin'] How would I search this array just like I would an active record object in Rails. For example, the query "sa" would return ['sandra', 'sam', 'sabrina']. Thanks! ...

Ruby - watir : Failed to get IEnum Interface

Hello, I'm using windows XP and I need to use watir with ruby, the installation went pretty well, my last try was following the instructions here http://stackoverflow.com/questions/3643179/failed-watir-installation-server-2003 and everything was ok except for this "ERROR: While generating documentation for builder-2.1.2" then the insta...

bundler clean downloaded gits

I'm using latest bundler with a lot of :git => ... in my Gemfile. Bundler does not seem to remove old/ unused git repositories it downloaded. Also I couldn't find a simple "bundle clean", just like "gem clean". Of course this would only work properly when using a separatestorage per project, but this is how I do it. So I wonder what's th...

Text Messages & Ruby on Rails

Is there any way to use text messages to CRUD data in a Rails app? For instance, a user would send a text message to a specific number and the Rails app could use that data in any way. Just wondering if there's a solution out there. ...

how does processing flow in haml work?

I have a run.haml file where I run a test suit. Everything works just fine but I want to display the text "Starting test suite: #{params['run']}" immediately after user clicks the link that leads him to this haml. the link clicked tells haml what suit needs to be executed %a(href="run?run=#{file}") Right now everything is displayed ...

Circular Dependency Grammar

I am using treetop to construct a grammar but am having problems with what seems to be a circular dependency. Note: this is not really a treetop question, but more of a question with loading files. Consider the following structure: test.rb lib/A.treetop lib/B.treetop lib/AB.treetop lib/all.rb And the sources for the files # test.rb ...

How can I programmatically determine which class/module defines a method being called?

In Ruby, how can I programmatically determine which class/module defines a method being called? Say in a given scope I invoke some_method(). In the same scope I'd like to invoke a function find_method(:some_method) that would return which Class, Singleton Class or Module defines some_method. Here's some code to illustrate what I mean:...

Parsing simple XML with Nokogiri

Let's say I have the following XML : <links> <item> <title>Title 1</title> <url>http://www.example.com/url-1&lt;/url&gt; </item> <item> <title>Title 2</title> <url>http://www.example.com/url-2&lt;/url&gt; </item> <item> <title>Title 3</title> <url>http://www.example.com/url-3&lt;/url&gt; </item> </l...

Is it okay to return presenter objects from a presenter when using the "Presenter Pattern"?

For example: class Tree has_many :apples end class Apple belongs_to :tree end class ApplePresenter presents :apple def name @apple.name.upcase end end class TreePresenter presents :tree def apples present_collection @tree.apples end end Using this, there's no need to duplicate the ApplePresenter methods a...

Which Ruby version is preferable?

Is there any reason to use 1.8.7 over 1.9.1 or is it always best to use the latest stable release? ...

ruby hash within hash and a singleton method- cant access instance variable

#!/usr/bin/ruby @data = { :student => { :id => '123477'} } class Student end s = Student.new def s.id @data[:student][:id] #how can I access the @data variable here I tried @data[:student][:id] doesnt work #I realize that data is outside of the scope of this method. However, is there any way! end puts s.id ...

how to valiation embed video in ruby?

please suggest me a gem or way validation embed video by ruby code. Example: Youtube Video, Google Video. ...

How to use rails3 with RedCloth. require 'RedCloth' not working

I have installed RedCloth, by using the devkit. Using gem install RedCloth. If I use plain irb, then require 'RedCloth' works fine. But if I use rails console and do require 'RedCloth', it says it can't find file to load. Please help. Rails 3.0.0 RedCloth 4.2.3 ...

How do i provide chunked data Transfer in IE(Internet Explorer)

Hi all, I am Running a rails application and uploading some large file (more than 2 GB) am able to do it from google chorme but when i try to do it from IE or mozia am gettind page does not exit and some times IE restart .Someone advised me to enable chunked transfer support in IE... I would like to ...

how to inject into sintra/haml?

I coded small web app that runs ant (batch file). The processing time of the batch file could take up to minutes. index.haml list all available ant files and run.haml runs them. The flow how it works now is that when I click a link from index.haml the ant script is run and after it finishes the whole run.haml page is sent to the browser...

Inserting an element in local HTML file

I am trying to write a Ruby script that would read a local HTML file, and insert some more HTML (basically a string) into it after a certain #divid. I am kinda noob so please don't hesitate to put in some code here. Thanks ...