ruby

Error running rake task from IDE

I am having a problem running the 'test' Rake task from IntelliJ Idea in Ruby On Rails application: *Error running test: File 'test/unit/autorunner.rb' wasnt found in $LOAD_PATH of Ruby SDK with interpreter: '{1}'* But the file is located at %RUBY_HOME%/lib/ruby/1.8/test/unit and I have no problems when running other rake tasks. Plea...

Ruby Custom Class to Model

I'm sure this is a completely obvious beginner question, but trying to find answers to beginner Ruby questions on google is turning out to be an exercise in futility. Anyway, suppose I have a database table that looks like this: MyMessage ================== int :id string :from string :to string :messagetext Now, if I need to expose ...

Testing strategies for Ruby on Rails & Twitter OAuth

I am developing an application that utilizes twitter oauth and ran into a brick wall trying to figure out how to test twitter oauth. Particularly trying to use Cucumber and Webrat/Selenium to do test the functionality -- Certain steps in the registration/logon process behave differently if the user has given oauth access to the app or no...

ActiveRecord Models - adding custom methods

Hi, I have 10 models and 3 of them need some additional custom methods which happen to be: has_staged_version? apply_staged_version discard_staged_version I want to define these methods once. I could create a custom subclass of ActiveRecord:Base, define the methods there, and have my 3 models inherit from it. But is there a more "Ru...

fractonology date select enigma

Can you please post your partial and controller code that you got working for this? I a mworking with the exact same problem and I cannot discern from the answer how you did it! Thanks. ...

Ruby open-uri file locking

I had an issue where downloading to a local file was locking it until I killed the ruby script. On a hunch, I changed the form of the call and now it doesn't lock the file. Can someone tell me why the second form below doesn't lock the file but the first one does? This form locks the local file: open(ver_local_zip, "w+").write(open(r...

Many-to-Many Relationship With Same Table (Ruby on Rails)

I'm working on a Rails app that has a "products" model. I want to be able to relate products to each other. Example: product 1 related to product 2, product 3, and vice versa. How would I accomplish this in Rails? I was thinking a join table, but since I'm using the same table as the point-of-relationship I'm not sure how that would work...

Sortable list without a database

I have a virtual shopping cart using sessions (sessions stored in the DB). I add products to the cart using an AJAX call. This list is also sortable. The problem I am having is updating the sort position of the products in the cart, given that the shopping cart is virtual. Can anyone help (specifically with the sortable_element :update ...

POSTing an HTML form to remote.cgi - written in Ruby?

I am working on a website hosted on microsoft's office live service. It has a contact form enabling visitors to get in touch with the owner. I want to write a Ruby script that sits on a seperate sever and which the form will POST to. It will parse the form data and email the details to a preset address. The script should then redirec...

Python's library support

Does Python seem to have greater library support than ruby? (For example, their OWL and RDF libraries seem much more developed. Is this true in general?) ...

Select random data with DataMapper

Im trying to select random datasets with DataMapper, but seems like there is no such function support. For example, i have set of data: +-------------------+ | ID | Name | Value | +-------------------+ | 1 | T1 | 123 | | 2 | T2 | 456 | | 3 | T3 | 789 | | 4 | T4 | 101 | | ----------------- | | N | Tn | value | ...

Rails: post data with a '+' is getting set to a blank

I have post data that includes a '+' sign. Once it makes it to the server the raw post data is showing the '+' sign but once the post data makes it into the param hash the '+' sign has been converted to a blank. Any ideas on how to make it NOT do that? ...

ruby script/plugin discover RuntimeError

Having problems when running this command on a rails installation on windows under a corporate firewall: ruby script/plugin discover I already set up the http_proxy variable on the system and this is the error I get: C:/Ruby/lib/ruby/1.8/open-uri.rb:203:in `open_http': Non-HTTP proxy URI: http-proxy(RuntimeError) from C:/...

How can I make this Shoes code from bogging down the computer?

This is the current state of my code, and, although I get the desired effect, it's not working in the manner in which I need it to. Because the program is in an infinite loop, obviously it will produce both background gradients on top of one another constantly, and 10 circles with each loop, and quickly they overproduce themselves and s...

Cucumber: Access current controller instance within step definitions

I'd like to access the controller instance in my cucumber step definitions. The purpose of this is so I can manipulate http cookie and session values. I'm pretty sure there's a way to do this via World, but I'm not sure how. In regards to Ryan's comment, I'm writing a feature for a page which requires a logged in user (via Authlogic)....

Is there too much Magic with Rails for a beginner?

Let me start by saying I know that both Ruby and Php are great languages and this is not intended to start a flame war. My question involves learning web development fundamentals and I have heard that Ruby on Rails can allow too much to be done in the background via Magic. I have so far done some learning in both Php and Ruby and while...

Idiomatic Ruby: data structure transformation

What's the "Rubyist" way to do the following data structure transformation: I have incoming = [ {:date => 20090501, :width => 2}, {:date => 20090501, :height => 7}, {:date => 20090501, :depth => 3}, {:date => 20090502, :width => 4}, {:date => 20090502, :heigh...

link_to_remote not updating div

I'm using link_to_remote to update a div asynchronously, but it does not work. I have to refresh the page in order to see the change. I use this to generate the links. http://ruby.pastebin.com/m1d83be81 "padding-left:30px", :display => "table-row" ) do %> { :success => 'entry_' + entry.id.to_s}, :url =>{ :controller =>...

What is a Namespace?

I didn't take the usual CS route to learning programming and I often hear about namespaces but I don't really understand the concept. The descriptions I've found online are usually in the context of C which I'm not familiar with. I am been doing Ruby for 2 years and I'm trying to get a deeper understanding of the language and OOP. ...

Why do test:units and test:functionals insist on running in development environment?

I'm trying to test some environment-specific settings (middleware to be specific, but it doesn't seem to matter), but I'm having trouble getting the tests to run in the correct environment. The symptoms: If I run ruby test/unit/my_test.rb, all is fine because the first thing it does is require test/test_helper.rb, which sets the enviro...