What I'm trying to find out is whether there is some sort of equivalence to what I see in Groovy as ExpandoMetaClasses. I've been reading about Open Classes but I can't quite see what level of scoping Ruby allows of the class modifications.
Borrowing an example from the blog above, in Groovy, I could modify Java's String class and add ...
I don't know what and when happend on my code but I got hundereds similar erros (not failures)
of this :
NameError: uninitialized constant ActiveSupport::Callbacks::Callback::NORMAL
And my tests function just go useless now, as even I put something like:
should "failed" do
assert false
end
It still returns passed, any idea ?
...
We're starting to standardise on a Ruby-based testing framework, having had some very good results out of RSpec and Cucumber-based testing recently. As this is a large enterprise, we're going to attempt to put together a "standard" set of Ruby gems for testing, knowing we're only ever going to get it ~90% right because of the broad mix ...
rake db:fixtures:load
The YAML file which I put in the test/fixtures following is imported automatically by DB.
Is there a method that converts the contents of the database into a YAML file for fixtures?
...
I am stuck with a problem when testing my controllers with RSpec - the response.body call always returns an empty string. In browser everything renders correctly, and cucumber feature tests seem to get it right, but RSpec fails each and every time.
Other expectations on the response object, such as response.should render_template('index...
I need to extract all MP3 titles from a fuzzy list in a list.
With Python this works for me fine:
import re
for i in re.compile('mmc.+?mp3').findall(open("tracklist.txt").read()): print i
How can I do that in Ruby?
...
> gem env gempath
/Users/davec/.gem/ruby/1.8:/opt/local/lib/ruby/gems/1.8
> head Rakefile
require 'rubygems'
puts Gem.path
require 'rake/clean'
require 'rake/testtask'
require 'rcov'
require 'rcov/rcovtask'
> rake
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
/Library/Ruby/Gems/1.8
rake aborted!
no such f...
This is the first time I am running Ruby on Rails.
When running the "blog" application I got the message
"We're sorry, but something went wrong.
We've been notified about this issue and we'll take a look at it
shortly."
Then I checked the CODE\blog\log\development.log and got this:
/!\ FAILSAFE /!\ Tue Jun 30 15:22:55 +0100 2009
Sta...
I am somewhat new to Ruby and although I find it to be a very intuitive language I am having some difficulty understanding how implicit return values behave.
I am working on a small program to grep Tomcat logs and generate pipe-delimited CSV files from the pertinent data. Here is a simplified example that I'm using to generate the line...
I have scripts that use "#!/usr/bin/env ruby" but I've switched to using Ruby Enterprise Edition instead of the default ruby that is included with Ubuntu server. Thus, the scripts freak out when I try to run them. How can I add the Ruby EE path to /usr/bin/env?
...
I'm looking for a ruby gem (or rails plugin) which abstracts the details of memcached in the same way that ActiveRecord abstracts the details of SQL. I am NOT looking for something to help cache ActiveRecord models in memcached. I'm sure there are approximately 4215 gems that will help with that problem.
Ideally what I'd like is to be a...
I have some photos that are split on successive pages through will_paginate plugin. When you open a photo and then return to all photos using a link, you always return to the first page (e.g. the photo is displayed on page 5, you open the photo, click a link to show all photos and expect that you are on page 5 again, but you are on page ...
Hello,
I spent the last three days working on the collection _ select form helper for my "listing" - form, where users can select a category.
I would like to have the category currently set in listing.category_id as the preselected value.
My view code looks like this:
<%= l.collection_select(:category_id, @category, :id, :name, optio...
In a Rails project I want to find the difference between two dates and then display it in natural language. Something like
>> (date1 - date2).to_natural_language
"3 years, 2 months, 1 week, 6 days"
Basically this for ruby.
Google and the Rails API haven't turned up anything. I've found some things that will give you the differen...
I need to write a GUI app in Ruby that supports easily changing the text color for items in a listbox (ownerdraw) on Linux.
What GUI framework is recommended?
...
For my school project I am buiding a time registration program. It is my first in ruby on rails, so even the simplest things are hard . ;)
The situation:
Users can work on a project, and I want to display in a chart how many hours each user worked on a project, let's say, each month. The chart plugin works like this:
first_serie = O...
Let's say I want some instance of String behave differently from other, "normal" instances - for example cancel the effect of the "upcase" method. I do the following:
class String
def foo
def self.upcase
self
end
self
end
end
It seems to work fine, and the way I need it:
puts "bar".upcase #=> "BAR"
puts "bar".fo...
Any ideas on how to get the width and height of the thumbnail image? photo.width returns the original photos width. I am storing the width of the thumbnail in the database, I'm just not sure how to access that object.
Doesn't work:
<%= image_tag photo.authenticated_s3_url(:medium),
:width => photo.width,
:he...
Hi,
I'm trying to to define a class called "HTML" to extend Nokogiri - which uses modules.
I tried the following:
require 'nokogiri'
class HTML
include Nokogiri
end
and
require 'nokogiri'
class HTML
extend Nokogiri
end
but so far it's been impossible that the class HTML inherit of all the functions in nokogiri. So stuf...
I'm using REXML library.
<foo>
<baa>value<baa>
<foo>
I want to get value belongs to baa.
How to code it ?
...