ruby

A question about $LOAD_PATH in Ruby

$: = '/users/joecool/rubylib' $: << '/users/joecool/rubylib' $:.unshift('/users/joecool/rubylib') ruby -c somescript.rb ruby -e "puts 'Hello, world!' Can someone direct me to some reading, so that I can figure out what this code does? ...

How to make a Rails view .erb file print the last part of an URL?

I'm brand-spanking new to Rails. I've learned how to make static controller actions and corresponding view files. Now I want to make it so that when I go to localhost:3000/hi/anita, the page says "Hi anita", but when I go to localhost:3000/hi/bob, it says "Hi bob". Of course, I don't want to make anita and bob actions. You get the idea. ...

Rails Model: Name -- First, Last

I'm fairly new to rails, working on a Rails 3 app with a Profile model for users. In the profile Model I'd like to have a "name" entry, and I'd like to be able to access logical variations of it using simple syntax like: user.profile.name = "John Doe" user.profile.name.first = "John" user.profile.name.last = "Doe" Is this possible, o...

RESTful nested conventional routing

Hi, I have the model: User -1---n- Transaction(amount,description, date) User -1---n- TransactionImport -1---n- TransactonImportField(name,value) (personal expense tracking app). What I want to achieve is this: User opens URL and pastes the CSV with the list of transactions. User submits it. System extracts data from CSV into Tra...

Nokogiri, different results of xpath in JRuby

Hi, I am getting different results from the same xpath expression in nokogiri when using ruby and jruby, In ruby the following xpath expression returns a node while in jruby it returns a nodeset: parent = node.xpath("./ancestor::node()[name(.) = 'div' or name(.) = 'p'][1]") Has anybody else noticed similar behaviour? Thanks Paul ...

Click at a scrollable data table with watir

Is there anyway of marking several different rows in a scrollable data table ? I know how to mark one row b.div(:id, "listProductsForm:productList:bc_4_0").click I just want to simulate the "Ctrl"- button is pressed down ...

Ruby Gem installation problem on Windows 7.

Hi there, I'm trying to install some Gems and need to run the following command: gem install mongrel mongrel_service mysql ruby-postgres oniguruma ultraviolet libxml-ruby --no-ri --no-rdoc --platform=mswin32 However, that --platform=mswin32 at the end of it bothers the hell out of me. I mean, my platform is x64 as it's supposed to b...

Is it possible to do translation of YAML files content using ruby-gettext package?

I have a site which is currently implementing i18n using ruby-gettext package methods. All of the marked content within *.rb, *.erb, *.rhtml can all be translated and displayed correctly. But for lots of text stored in *.yml can't be displayed correctly although those marked strings have been inside of po files. Original yml file exampl...

How do i provide password for su command while using net/telnet in ruby

Hi all , I am using Net/TELNET to connect to remote host trying to run su command in order to get root privilage. This is how I am doing it require 'net/telnet' localhost = Net::Telnet::new("Host" => "192.147.217.27", "Timeout" => 50, "Prompt" => /[$%#>] \z/n) localhost.login("...

Builder Pattern in Ruby with YAML

I have an instance of the Builder pattern in my project right now. Currently, the supported output format is CSV, however I would now like to include YAML. Easy, I thought. I have all of the supporting code in to make the type change. I'm finding myself to be in a bit of a complex. The intent of using the Builder pattern was to construc...

Adding a stylesheet declaration to ci_reporter xml files automatically

Hey all, I am not a programmer, so please be forgiving if my problem is fairly easy to solve for many of you (yet I still might find it confusing). The problem I am having is with ci_reporter, a gem for use with Watir and Test/Unit. It is outputting the test results from a Watir test to an xml file. Great so far. Unfortunately I can...

C:/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/net-ssh-1.1.2/lib/net/ssh/session.rb:143:in `initialize': dvsdkval (Net::SSH::AuthenticationFail

HI ALL , i am getting this error while ploying net/ssh in ruby this is my code require 'rubygems' require 'net/ssh' HOST = '192.118.217.17' USER = 'dvsdkval' PASS = 'dvsdkval' Net::SSH.start( HOST, USER, :password => PASS ) do|ssh| result = ssh.exec!('ls') puts result end ...

Toggle element by class name

I would like to toggle (hide/show) several elements of my web page. All those elements are in between this tag: <div class="class_name">to toggle</div> <div class="class_name">to toggle2</div> I would like to use javascript to toggle all the elements with class=class_name when the user clicks on a button. So far all the code I ...

How do I split apart a CSV string in Ruby?

Hi all. I have this line as an example from a CSV file: 2412,21,"Which of the following is not found in all cells?","Curriculum","Life and Living Processes, Life Processes",,,1,0,"endofline" I want to split it into an array. The immediate thought is to just split on commas, but some of the strings have commas in them, eg "Life and L...

rake spec cucumber complains about "no such file to load - ZenTest" despite ZenTest being installed

Hello! /home/soroush/.gem/ruby/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is deprecated and will be removed on or after August 2010. Use #requirement no such file to load -- ZenTest /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' /usr/loca...

Error installing mysql2: Failed to build gem native extension.

Windowsxp. Ruby192. Rails installed. Mysql installed. When I try to run gem install mysql2 (or bundle install) I get errors: C:\ruby\cred2>gem install mysql2 Building native extensions. This could take a while... ERROR: Error installing mysql2: ERROR: Failed to build gem native extension. C:/Ruby192/bin/ruby.exe extconf.rb ch...

How to write this MySql query using Rails3 syntax?

SELECT `subscriptions`.*, DATE_ADD(`subscriptions`.created_at, INTERVAL `packages`.validity DAY) as end_date FROM `subscriptions` INNER JOIN `packages` ON `packages`.`id` = `subscriptions`.`package_id` order by end_date; ...

rdoc, darkfish, and the :call-seq: tag

I'm in the process of documenting a Ruby project with rdoc, and I discovered the darkfish rdoc formatter. I really like it, but the :call-seq: tag no longer works. Instead, it puts the literal string :call-seq: in the documentation and then formats the call sequence itself as a code block. I don't want to just take all of the :call-se...

Best Zip Code Plugin for Ruby

I need to find the city and state from a zip code. Does anyone know a good plugin/API that I can use to do this? ...

Rails 3 Clone ActiveRecord Model with Submodels

Basically I have two chains of models, one holds 'predicted data' and one holds 'actual data'. I would like to copy all predicted data to actual when an actual is created. def init_data employees = Employee.all employees.each do |e| t = e.template ed = t.effective_dates.first if ed and !e.routes routes = ed.routes....