ruby

What's a good swiss-army framework for the next 5 years?

Basically, we want to use no flash, and eschew php where possible (for marketing reasons). Right now, I'm looking at Ruby on Rails and like what I see... but I'm not really a programmer, having working primarily with Wordpress, Drupal, and Joomla for the past 10 years. Our sites need to have a lot of custom apps built into them (video ...

Self-referential has_many :through with customized :primary key issue

I'm trying to emulate the twitter model in my Rails 2.3.8 app (ruby 1.8.7) class Connection < ActiveRecord::Base belongs_to :subject, :foreign_key => 'subject_id', :primary_key => 'user_id', :class_name => 'User' belongs_to :follower, :foreign_key => 'follower_id', :primary_key => 'user_id', :class_name => 'User' end class User < A...

Checking validity of message sizes before sending to Twitter...

I have an ActivityStream that sends messages to Twitter. There is a short and long format for each message. It's possible that both could be over 140 chars, but the short format has much lower probability. By default, I start with the long version, then if that is over 140 chars, I use the short version. Again, there's a chance the s...

Tk: Event for entering with mouse button held down

I'm writing a video game mapping program in Ruby that has uses Tk for GUI. To give you some background, the level map ($Map) is a large TkCanvas covered with TkcImages - one for each tile in the level. I wanted to set it up so that the user could edit the level by clicking and dragging the mouse around to paint tiles. So I figured I c...

Follow up to changing Date format from Time.now to post.created_at

I previously asked a question on stack overflow about how to format my date in a readable manner. This was the gist of it was this. How do I take 2010-06-14 19:01:00 UTC and turn it into June 14th, 2010 The answer that I used was calling post.date and simply adding the below to post.rb @date = Time.now @date.strftime("%B %d, %Y"...

In Ruby, how do you execute rspec code from a string rather than from a file?

I am trying to execute rspec code passed in to a Ruby process as a string. How can I execute rspec from within a Ruby process rather than from the commandline and capture the results? # Ruby code code = ' #solution class User def in_role?(role) true end end #Tests to pass describe User do it "should be in any roles ass...

On MongoMapper, what is the difference between a Document and an EmbeddedDocument?

This example makes it seem like both are used (included) in order to make a class a persistent model, but it is not clear when I should use one or the other. ...

Are there any reserved key names in MongoMapper?

Could I declare a model with a key called :key, for instance? Is there any word I can't use for a key? ...

rexml in ruby (use of xml in ruby)

I am new to ruby so what i want to know is whts the use of xml in ruby means for what purpose rexml is there in ruby cud any body give me example like by adding some xml documents in our ruby programme we have this kind of benefit means i want to know for what purpose xml is used in ruby .sorry if it looks stupid question but i want to...

installing ruby 1.8.7 on MAC pc

hi, I am a newbie to MAC environment .I am working on MAC OSX(10.5.1). I need to install ruby 1.8.7 on the MAC PC without disturbing the already existing ruby 1.8.6 Can anybody please provide a step by step approach ? Regards, Sun ...

How to store the result of my algorithm?

I have an algorithm that searches through all of my sites users, finding those which share a common property with the user using the algorithm (by going to a certain page). It can find multiple users, each can have multiple shared properties. The algorithm works fine, in terms of finding the matches, but I'm having trouble working out ho...

require not working inside a spec

Hi, I've got an rspec test which looks something like this: require 'require_all' require_rel '../spec_helper' describe "HtmlEntities" do ...some tests end And I'm invoking it from a rake task that looks like require 'rspec/core/rake_task' Rspec::Core::RakeTask.new(:spec) do |spec| # spec.libs << 'lib' << 'spec' # spec.spec_file...

Language to constrain large datasets for ruby/java and javascript

I got a backend web service containing massive amounts of data that I have control over and I need to fetch data from it through a browser frontend. The frontends task is to simply display the data in a paged table but the user should be able to dynamically constrain the data based on the fields and i can't load the entire matching data ...

Evaluate %x() to True or False in Ruby

I'm doing something like this: $printer = %x(lpstat -p | grep -q "Eileen" && echo "true" || echo "nil").chomp if $printer == "true" puts "do something here" else puts "do something else" end Is there an easier/shorter way to do that? I'm just checking to see if a print queue exists, and needing to do one thing if it does and ano...

To continually pull result from the server via Ajax until timeout or getting result.

Hi guys, I would like to make an Ajax request to the server, which replies a job status and result. If the status is "Error" or "Ok", the client should show the result (containing HTML code) to the user. However, if the status is "Waiting", the client should wait for a few seconds and then automatically send the same Ajax request again....

Datamapper at dreamhost

Has anyone had success with Datamapper and Dreamhost? Anytime it makes a request to the database, I get the 500 internal server error. Dreamhost has no clue and isn't answering a support ticket. I have confirmed the gem is installed, and the connection is made. If I enter invalid connection credentials, passenger kicks out an error. ...

Rails File I/O: What works in Ruby doesn't work in Rails?

So, I wrote a simple Ruby class, and put it in my rails /lib directory. This class has the following method: def Image.make_specific_image(paths, newfilename) puts "making specific image" @new_image = File.open(newfilename, "w") puts @new_image.inspect @@blank.each(">") do |line| puts line + "~~~~~" @new_image.puts line if...

Mocha Mock Carries To Another Test

I have been following the 15 TDD steps to create a Rails application guide - but have run into an issue I cannot seem to resolve. For the functional test of the WordsController, I have the following code: class WordsControllerTest < ActionController::TestCase test "should get learn" do get 'learn' assert_response :success ...

retrieving text in selenium using xpath?

Hi i have this HTML code: <tr class="odd events" style=""> <tr> <a title="Expand to see Actions" class="toggleEvent" name="actions_for_host_1" href="#"></a> <td id="7" colspan="6"> <div> <ul> <li>Low Alarm at 2010/06/25 07:09 ( <span title="2010/06/25 14:09 (UTC)" class="time_helper">Pacific</span> )</li> </...

How can I read directory or file information using Ruby/Rails or possibly PHP?

Hi, I need to reprocess some files using attachment_fu, but not all of the files. I've seen a few posts asked about reading and listing files in a directory using Ruby, but does anyone know how to select the files based on the upload date or file parameters? I can use either the date parameters for when the file was uploaded or loo...