ruby

Rails route error? uninitialized constant ActiveResource::Base

I'm following the Getting Started with Rails guide but ran into an issue opening http://localhost:3000 Shell output: [2010-03-23 19:19:14] ERROR NameError: uninitialized constant ActiveResource::Base Error in the browser: Internal Server Error uninitialized constant ActiveResource::Base WEBrick/1.3.1 (Ruby/1.8.7/2009-06-12) at local...

class << self idiom in Ruby

I suppose my question is exactly what the subject depicts, what does: class << self do in Ruby? ...

HTML to Plain Text with Ruby?

Is there anything out there to convert html to plain text (maybe a nokogiri script)? Something that would keep the line breaks, but that's about it. If I write something on googledocs, like this, and run that command, it outputs (removing the css and javascript), this: \n\n\n\n\nh1. Test&nbsp;h2. HELLO THEREI am some teexton the next ...

Ruby hpricot does not like dash in symbol, is there a workaround?

I am trying to parse an xml file with hpricot. The xml element that I am trying to get has a dash though and hence the issue that I am facing xml <xliff xmlns="urn:oasis:names:tc:xliff:document:1.1" version="1.1"> <trans-unit> <source>"%0" can not be found. Please try again.</source> <target>"%0" can not be found. Please try ...

how .hash string method work ?

I'm just a newbie to ruby. I've seen a string method (String).hash . For example, in irb, I've tried >> "mgpyone".hash returns => 144611910 how does this method works ? ...

Passing hash as values in hidden_field_tag

I am trying to pass some filters in my params through a form like so: hidden_field_tag "filters", params[:filters] For some reason the params get changed in the next page. For example, if params[:filters] used to be... "filters"=>{"name_like_any"=>["apple"]} [1] ...it gets changed to... "filters"=>"{\"name_like_any\"=>[\"apple\"]}"...

For what programs are Objective C and Ruby ideal on the Mac?

Hi, as a Mac outsider it seems that two popular programming languages on the Mac appear to be Objective C and Ruby. From what I understand the main API Cocoa seems to be written in and optimized for Objective C, but it is also possible to use Ruby for that. Are there different areas where each language is ideal, for example, I could im...

Ruby rail debug output

Hi all: I am just starting to write ruby rails. I wrote a controller but is getting wrong number of "arguments (1 for 0)" error, I can't understand why. It has no information on where the error occurred? It has a full list of stack traces but my controller file is not in there! In my controller I have just two methods, that I was going...

Basic Ruby on Rails Question about routing

I have a controller without any related model. This controller is to span some information from various models. I have lots of actions there, which define certain views on the page. What would be the best way to organize routes for this controller? What I would like is to have /dashboard/something point to any action in the dashboard c...

Rails. How to extend controller class from plugin without any modification in controller file?

I'm use Rails 2.2.2. Rails manual said, the way to extend controller from plug-in is: Plugin: module Plug def self.included(base) base.extend ClassMethods base.send :include, InstanceMethods base.helper JumpLinksHelper end module InstanceMethods def new_controller_metod ... end end module ClassMethods end end ...

I have a comment model, what to use in my views? @comment, :comment or comment?

I have a comment model, I've seen examples of using @comment, :comment, comment to reference the object in MVC. how do I know which is which? Is there a distinction? ...

Capturing network traffic in ruby - pcap related issues

What I need is to write very simple application, which would listen to network traffic, filter out some packets based on various layer 4/5 information and then dump those information into database. I am quite confused on which pcap gem/plugin should I use. The basic pcap implemention seem to be a bit outdated (no changes since 2001) and...

Convert xsd to ruby classes

Is there an analog of xsd tool from .NET framework in ruby, to create classes for serialization data to xml with appropriate xsd. I've found xsd2ruby from soap4r, but there is no documentation. And rxsd, that seems not works. ...

Ruby, post and redirect

Hi! I have situation like this: user submits form with action='/pay' in '/pay' I have to add some additional parameters and send post request to www.paymentprovider.com/new_payment The problem is that I want to post and redirect (at the same time) user to this new website www.paymentprovider.com/new_payment. Currently I am using N...

AES java encoding, ruby decoding

Hi all, I'm trying to AES encode data in java, send it over the network and decode it in ruby. Works fine with basic strings, but once the string's length is 16 bytes or more, I have garbage at the encode of the decoded ruby string. I guess it has to do with padding (not sure though since it affects even strings with the exact size of ...

Ruby getting the diagonal elements in a 2d Array

Hi, I was trying some problems with my 2D ruby array and my LOC reduces a lot when I do array slicing. So for example, require "test/unit" class LibraryTest < Test::Unit::TestCase def test_box array = [[1,2,3,4],[3,4,5,6], [5,6,7,8], [2,3,4,5]] puts array[1][2..3] # 5, 6 puts array[1..2][1] # 5, 6, 7, 8 end end I wan...

Ruby - Subclassing array to make it randomize when flattened

I'm trying to subclass Array in ruby to make it randomize its elements when flatten! is called. Looking at the source code for Array#flatten (http://ruby-doc.org/core/classes/Array.src/M002218.html), it looks like it should recursively call flatten! on any array contained within an array. So, I tried doing something like this: class R...

Am I reindexing this Sphinx index correctly?

According to the Thinking Sphinx docs... Turning on delta indexing does not remove the need for regularly running a full re-index ... So I set up this cron job... 50 10 * * * cd /var/www/my_app/current && /opt/ruby/bin/rake thinking_sphinx:index RAILS_ENV=production >> /var/www/my_app/current/log/reindexing.log 2>&1 Is...

Exporting ActiveRecord objects into POROs

Hello, I'm developing a "script generator" to automatize some processes at work. It has a Rails application running on a server that stores all data needed to make the script and generates the script itself at the end of the process. The problem I am having is how to export the data from the ActiveRecord format to Plain Old Ruby Object...

Web framework for an application utilizing existing database?

A legacy web application written using PHP and utilizing MySql database needs to be rewritten completely. However, the existing database structure must not be changed at all. I'm looking for suggestions on which framework would be most suitable for this task? Language candidates are Python, PHP, Ruby and Java. According to many sources...