ruby

Ruby W3C_Validators and Proxy

Hi, I'm trying to use the w3c_validators Ruby gem and I'm inside a proxy. So I wrote up a monkey patch that overrides the send_request method (validators.rb) and it seems to take the the settings okay. However, once I make the request I encounter this error: 302 "Found" (Net::HTTPRetriableError) I can't tell if this redirect is from...

Replacing characters in Ruby string according to some rule

In Ruby, I have a string of identical characters -- let's say they're all exclamation points, as in !!!!. I would like to replace the characters at certain indices with '*' if the integer corresponding to that index meets some criteria. For example, let's say I want to replace all the characters whose indices are even numbers and are gr...

Voting Functionality Ruby on Rails - Easy Question

I want to add a "like" functionality to a blog I am creating in Ruby on Rails to let people "thumbs up" a post. Then I would like to be able to display the most liked posts in the side bar. I am new to rails so rely heavily on tutorials and stack overflow. Any good resources or what is this even called. I assumed "voting" for this questi...

How to get the day of year in ruby?

What is the best way to get the day of year of an specific date in Ruby? For example: 31/dec/2009 -> 365, 01/feb/2008 -> 32, etc ...

How to use rspec to test named routes?

Hi there, Given I have a named route: map.some_route '/some_routes/:id', :controller => 'some', :action => 'other' How do I use the routing spec file 'spec/routing/some_routing_spec.rb' to test for that named route? I've tried this after the "describe SomeRouteController" block and it doesn't work, I get 'undefined method "helper": ...

How to find date of end of week in Ruby?

Hi, I have the following date object in ruby Date.new(2009, 11, 19) How would you find the next friday? Cheers ...

Is there any way to use the command line to debug an ERB file?

Is there any way to use the command line to debug an ERB file? I would like to know if there is any way to get rdebug or rdebug-ide to do this. ...

How to count duplicates in Ruby Arrays

How do you count duplicates in a ruby array? For example, if my array had three a's, how could I count that ...

AJAX/Javascript Error Ruby on Rails...

Ok so here is where I am at. I have three different things here and I am very close to getting it to work. I have a form with a checkbox = value of 1 that collects a "vote" for a "post" and sends it to the database with the post_id. This works great. I have a partial template that rendors that particular posts votes back underneath t...

Recieving a 404 HTTPError on a working page in Ruby Script

This is my first time asking a question, please be gentle! I have a Rails application that handles content for a whole bunch of domains (over 100 so far). Each domain either points to where my app is hosted (Heroku, if you're interested), or the original place it was hosted. Every time a domain is ready, it needs to point to the herok...

Hiding Checkbox & Assigning Value - Ruby on Rails - Easy Question...

I am trying to hide a checkbox and assign a default value of 1 such that the submit button only shows. Here is my form. Just wondering as the proper format as I am new to rails. I think you can do this with helpers but was wondering if I can just include it in the form. Here is the form: <% remote_form_for [@post, Vote.new] do |f| %> ...

Displaying record count - Ruby on Rails - Ajax

I am new to rails so sorry if sometimes I don't make much sense. Here is what I am trying to do. I am trying to build a vote system. So next to a blog post there is a link that says 'vote' (will probably say like later). So far I have working: when the vote button is clicked, a value of '1' is delivered to the vote table and then that pa...

Comparing ruby hashes

Hi I have two ruby hashes (which are essentially models) and am trying to find the differences between them, one is an old instance of an object where the other has new values assigned to some attributes. I'm trying to determine which keys have changed, but there doesn't seem to be anything built into the Hash for this. I can think of...

Easy Ruby libraries to understand for beginner

Hi. I'm at the point in learning Ruby where I'd like to look at some small-ish libraries' source code to see how they were built. I do not know what is considered a small library but was hoping SO could recommend some easy-to-understand libraries to study. So if anyone knows a very tiny library or two that's a good example for novice Ru...

Partial not receiving all variables from :locals

In my controller I have: - @items.each do |item| = render :partial => 'item', :locals => { :item => item, :draggable => true } And in the item partial I have: %span{:id => "item_#{item.id}", :class => 'item'} = item.name - if defined?(draggable) = draggable_element "item_#{item.id}", :revert => true This is not working, h...

Duplicates in hash

I am working on http://rubyquiz.com/quiz28.html and am almost done except for one little bug. In the following: prompts is an array, which for arguments sake is ["one", "two", "three", "three", "four] def ask_reader(prompts) @answers = {} for p in prompts puts "Give me a #{p}" @answers[p] = gets.chomp end en...

what do these ruby warnings mean ?

cqq.rb:96 **warning: Statement not reached.** /root/newpackage/lib.rb:727 **warning: instance variable @object not initialized** Error: Your application used more memory than the safety cap of 500m. Specify -J-Xmx####m to increase it (#### = cap size in MB). Exception trace follows: java.lang.OutOfMemoryError: Java heap space curiosu...

Best way to create GOOD LOOKING, multi-platform, desktop Ruby apps?

Hi everyone, I've got an idea for an idiotically simple application, one that converts HAML and SASS into HTML & CSS files for the user by watching directory changes (like Compass). Almost all the components are already available in the community, I just need to figure out what to use for the front-end. The catch: It must be: a stand...

Ruby XML::Builder with hyphen in Element name

I'm trying to generate some XML using XML::Builder, but my element names need to have hyphens in it. When I try I get undefined methods, with the element name being truncated at the hyphen xml.instruct! xml.update-manifest do xml.latest-id @latest_version_update.guid xml.download-url @latest_version_update.download_url xml.relea...

Ruby Regexp to extract specific elements in an XML string

I have a simple XML string, that is more or less always the same. I'd rather avoid using an XML parser for such a little piece of code, and I though Regexp would help. The XML string looks like : <?xml version="1.0"?> <methodCall> <methodName>weblogUpdates.extendedPing</methodName> <params> <param> <value>Official Google...