Hi all,
I'm trying to retrieve the "onclick" attribute value from the below link:
<a onclick="test" href="myurl">aaa</a>
Using link.href works fine (So I know link is the correct object) however when using link.attribute_value("onclick") what I get is a win32 object (puts shows #<WIN32OLE:0x2cbdf10> instead of the "test" string). ...
I am getting a beautiful error :
failed with NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[] - 3 failed attempts
My Controller:
CardSignup.all.each do |user|
Delayed::Job.enqueue MassEmail.new(user, params[:subject]...
I followed this tutorial more or less... I installed the passenger gem, executed passenger-install-ginx-module, sucessfully installed nginx and inserted this into the config:
server {
listen 80;
server_name localhost;
root /home/admin/sintest/public; # <--- be sure to point to 'public'!
passenger_enabled on;
}
In /home/admin...
I have a nested hash:
{
:KeyA => {
:KeyB => "hello",
:KeyC => {
:KeyD => "foo",
:KeyE => "bar"
}
}
}
if I pass this to ERB I can do:
<%= config[:KeyA][:KeyC][:KeyD] %>
and get:
foo
However this doesnt work with Liquid :(
If I do:...
I'm learning Ruby but came across a very annoying thing: I can't use curly brackets in If else constructs! I left Python as I didn't feel comfortable with indenting the statements carefully.
Is this the same way in Ruby also? For example: Can I write something like this:
if token == "hello" {
puts "hello encountered"
# lots of lin...
I'm running Redis and connecting from Ruby using ezmobius's Redis gem[1].
Periodically (about once a day) I get a series of exceptions in my Rails app caused by Redis returning strange results.
They are often triggered by an exception such at this:
Redis::ProtocolError: Protocol error, got '3' as initial reply byte ...
I have a rails 2.3.5 app getting upgraded to Rails 3. I did every thing I am required to do for upgrading and when I start the rails server using
rails server
it gives me this
Please switch to Ruby 1.9's standard CSV library. It's FasterCSV plus
support for Ruby 1.9's m17n encoding engine.
I am using ruby-1.9.2-p0 and have faster...
I tried rake gems:install but I get
No such file or directory - /Users/macuser/Sites/hq_channel/config/database.yml
I bet the default is set wrong.
What file do I need to change? And where do I find what to change it to?
...
I am trying to create a rails template that will add code to files at particular line numbers. For example I need to add a route to the config/routes.rb
I have tried sed, gsed(only cause I am on a mac and they say that sed has problems with insert and append), anyway, I was not able to achieve the result I want.
Any help on this will b...
In my current Rails (Rails 2.3.5, Ruby 1.8.7) app, if I would like to be able to define a helper like:
def product_image_tag(product, size=nil)
html = ''
pi = product.product_images.first.filename
pi = "products/#{pi}"
pa = product.product_images.first.alt_text
if pi.nil? || pi.empty?
html = image_tag("http...
I find my self doing this alot:
optparse = OptionParser.new do |opts|
options[:directory] = "/tmp/"
opts.on('-d','--dir DIR', String, 'Directory to put the output in.') do |x|
raise "No such directory" unless File.directory?(x)
options[:directory] = x
end
end
It would be nicer if I could specify Dir or Pathname instead o...
I have a very large PDF File (200,000 KB or more) which contains a series of pages containing nothing but tables. I'd like to somehow parse this information using Ruby, and import the resultant data into a MySQL database.
Does anyone know of any methods for pulling this data out of the PDF? The data is formatted in the following manne...
When I try and define (but not implement an it test) (pending method) using RSpec
describe "test" do
it "should not fail, but does"
end
I get this error when I try and run
ArgumentError in 'should not fail, but does'
wrong number of arguments (1 for 0)
Does anyone know why this is happening? Am I doing something wrong? (I am us...
Using Rails 2.3.2 (not in a good situation to upgrade at the moment) with ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]. Getting the following error when trying to save when doing validations on the model, if the validations are :on => :update. If I change the validations to :on => :create and create a new record, I don't...
Possible Duplicates:
What is the best way to learn Ruby?
Explain Iterator Syntax on Ruby on Rails
I'm still learning ruby, ruby on rails and such. I'm getting better at understanding all the ruby and rails syntax but this one has me a little stumped.
respond_to do |format|
format.html # index.html.erb
format.xml { rend...
There seems to be two matrix modules in Ruby that I've found
Matrix: Part of core Ruby it seems
NMatrix: Part of the NArray library
At the moment it seems NMatrix is faster, has some more helpful methods, but require a bit more setup.
Is there anyone with experience of both who can give a rough overview of why I should use one over ...
Trivial Sinatra application:
require 'rubygems'
require 'sinatra/base'
require 'haml'
class InfoController < Sinatra::Base
get "/" do
haml :index
end
end
And my test:
describe InfoController do
include Rack::Test::Methods
def app
InfoController
end
it "should return the index page when visiting the root of the ...
I'm not sure what the best word to use here. By "pyramidizing", I mean:
[1,2,3,4].pyramidize # => [1,1,1,1,2,2,2,3,3,4]
["a","b","c","d"].pyramidize # => ["a","a","a","a","b","b","b","c","c","d"]
To represent visually, it could be thought of as:
[ 1,1,1,1,
2,2,2,
3,3,
4 ]
Is there a way to do this that maximizes e...
I'm a Ruby newbie (started 4 days ago and hey it rhymes!) and decided to code a simple little tool for fun/learning. The following code was the result. It works fine, but I would really appreciate critique from some more experienced Ruby developers. I'm looking for comments on style, verbosity, and any misc. tips/tricks.
By the way, I'm...
I'm trying to write a function that pulls the lowest order number out of an integer. Eg:
> 24689.lowest_order
=> 9
Thus far I have:
class Integer
def lowest_order
Integer (self / 10.0 - self / 10) * 10
end
end
And it works....sometimes:
irb(main):002:0> n = 235
=> 235
irb(main):007:0> n.class
=> Fixnum
irb(main):004:0> n...