I'm trying to add an attribute to an existing Nokogiri node. What I've done is this:
node.attributes['foobar'] = Nokogiri::XML::Attr.new('foo', 'bar')
But I get the error:
TypeError Exception: wrong argument type String (expected Data)
What is a Data data type, and how do I add an attribute to the Nokogiri object?
Thanks!
...
Thank you for taking your time in reading this. I am just getting started with running Watir in Eclipse. When I try to load the require 'firewatir' statement on the top of the page, I receieve this error in the Eclipse console:
in inherited': undefined methoddemodulize' for "FireWatir::Pre":String (NoMethodError)
Running require firewa...
I am using http://tagaholic.me/hirb/ to format AR queries in console with pretty, MySQL like table views.
The problem is, that by default Rails 3 .where queries, reaturned as ActiveRecord::Relation arent displayed in a table format. With imported table method everything is formatted properly. How to set default display to table in Hirb ...
There is a sound library written by _why called bloops. It runs fine, but within several minutes, it crashes. Following is a sample code:
#!/usr/bin/env ruby
require 'bloops'
loop {
b = Bloops.new
b.tempo = 320
b.tune(b.sound(Bloops::SAWTOOTH), "c")
b.play
sleep 1 until b.stopped?
b.clear
}
The error message is like this:
Expressi...
Hello, I am having trouble getting apache to serve a file through the XSendFile when it is in a directory mounted with samba.
To give a little background: I have a Ruby on Rails app that is slowly replacing an ASP.NET application, and I have it running on a linux server running apache2 and passenger. The Windows machine that is running...
Lets say I have an array
[0, 132, 432, 342, 234]
What is the easiest way to get rid of the first element? (0)
...
I'd like to read the logic code of =, but can't find it.
UPDATE:
I found the test_multi method text/ruby/test_assignment.rb. It's Ruby code, but seems will let me to the destination.
The reason I want to check the code is find how it handles multi-assignment. Like a,b,c = [1,2,3].
UPDATE:
I found keywords "MASGN" and led me to
c...
I have the nested resource "resources :comments" added to a lot of parent resources as follows (using Rails 3):
resources :cusines do
resources :comments
end
resources :recipes do
resources :comments
end
resources :chefs do
resources :comments
end
resources :countries do
resources :comments
end
etc., etc., etc.
Since I hav...
Hello there!
I'm getting myself confused as to how to get a JRuby app cranking on App Engine.
I know that you can get started using the appengine-jruby "gem" (Note: I'm a Java programmer, so this is all completely new to me). I've also seen some talk about Warbler, and am getting the impression that I could probably use Warbler someho...
I started using Rails 2 last April but stopped this June because I thought learning it when Rails 3 was released would be more practical since a lot of it was completely refactored and restructured. I used to work with Ubuntu 10.04 (with SQLite3 as the default db) but now I'm using Windows 7 and MySQL 5. I already installed the gem adapt...
Ok so I am having a problem with doing multiple forms in rails. here is the code below
Models
class Profile < ActiveRecord::Base
belongs_to :user
has_attached_file :avatar, :styles => { :medium => "134x137>", :thumb => "111x111>", :tiny => "32x38>" }
validates_attachment_content_type :avatar, :content_type => ['image/pjpeg','im...
Hi,
Run the following code,
a = [1, 2, 3, 4, 5]
head, *tail = a
p head
p tail
You will get the result
1
[2, 3, 4, 5]
Who can help me to explain the statement head,*tail = a, Thanks!
...
I just found a bug in some number manipulations in my program and I'm getting a FloatDomainError (NaN)
So I started logging the number passed in with:
if(metric.is_a?(Numeric))
self.metric = metric
else
LOGGER.warn("metric #{metric} is not a number")
self.metric=0
end
But the number being passed in is NaN which apparently is_a?...
I can't seem to find a way to switch versions of PHP quickly. Is there something equivalent to ruby version manager for php? I need to switch between 5.3 and 5.2 on os x.
thanks,
-jm
...
From this article http://www.stuartellis.eu/articles/erb referring to thread safety levels:
"At this level, the specified binding must be marked as trusted for ERB to use it."
I've searched high and low and haven't found a way to "mark" a Binding as "trusted".
Will somebody please enlighten me?
...
I just upgraded to Rails3, Ruby 1.9.2 and the latest HAML gem.
This code used to work:
= allowed? do
= link_to('New', new_video_path)
Now allowed? yields 0.
It works if I do:
= allowed?{ link_to('New', new_video_path) }
What gives?
...
I'm doing a program and I would like to output a menu with two submenus in a module. I only want the main menu to show when you run the program. Then from the main menu be able to navigate to the submenus and back. If anyone could find a better way doing this (which I'm positive there is) please do say so. I'm not even sure this will wor...
I'm using RVM to manage my Ruby environment on OSX, and currently it's interpreting '1.9.2' as ruby-1.9.2-rc2 instead of the final release. How can I update this to make it behave as expected?
...
Hi,
We have a "legacy" flash application relying on PHP to deliver it's data, but the server side is now being upgraded to Rails 3.
For various reasons we don't want to change the flash, so we need to be able to route http requests like this: http://www.example.com/somefile.php?param=123&otherone=123457 to RESTful rails routes.
I...
I'm looking for an example of how, in Ruby, a C like language, or pseudo code, to create the Cartesian product of a variable number of arrays of integers, each of differing length, and step through the results in a particular order:
So given, [1,2,3],[1,2,3],[1,2,3]:
[1, 1, 1]
[2, 1, 1]
[1, 2, 1]
[1, 1, 2]
[2, 2, 1]
[1, 2, 2]
[2, 1, 2]...