class Collector
class ContentNotFound < Exception
end
class DuplicateContent < Exception
end
end
begin
raise Collector::ContentNotFound.new
rescue
puts "catch"
end
When I run the script I don't get "catch" message I see error:
lib/collector/exception.rb:10:in `<main>': Collector::ContentNotFound (Collector::ContentNotFou...
Hello all, I have the following model, Purchase, on my Rails app:
class Purchase < ActiveRecord::Base
[...]
belongs_to :payment, :validate => true
belongs_to :day, :foreign_key => :day_day, :primary_key => :day,
:counter_cache => true
[...]
end
And I have the Day model:
class Day < ActiveRecord::Base
[...]
has_many :...
I'm having trouble understanding the following error with Ruby's Rake.
C:\>gem install rake
Successfully installed rake-0.8.7
1 gem installed
Installing ri documentation for rake-0.8.7...
Installing RDoc documentation for rake-0.8.7...
C:\>rake
C:/Ruby192/lib/ruby/1.9.1/rubygems.rb:340:in `bin_path': can't find executable r
ake for...
I've been trying to run part of a Peepcode tutorial 'Meet Sinatra' with Shotgun (allows you to skip rebooting your web server for every change you make). The error threw up the following message:
$ shotgun simple.rb /Library/Ruby/Gems/1.8/gems/shotgun-0.8/bin/shotgun:115: undefined methoddefault' for Rack::Handler:Module (NoMethodErro...
I have this rails find that i need to get the id as well but if i put the id in the :select wont it effect the query and is there another way to get the id
@past_requests = Request.find_all_by_artist(name, :conditions => ["showdate < ?", Time.now], :select => "distinct venue, showdate")
...
I am trying to build a survey app in rails 3. Basically I need to make a wa yi to accept responses from a set of questions. (surveys have many questions and responses.) I got it to render but when I submit it it sends as a put instead of a post. So is there any way I can add a custom put route to my response controller?
...
I want to subtract the result of File.mtime and Date.today. Time and weekends are ignored. I am after something like
Date.today - File.mtime
File.mtime gives me Fri Oct 08 11:00:18 +1100 2010
and
Date.today 2010-10-11
I thought that to_s() would work for me but File.mtime(filename).to_s gives me the same result like File.mtime(filena...
Hi there,
I've been spending the last few days banging my head against the wall on supporting the ability to add a contact to the Google Contacts API in my Rails 3 application. Despite many false starts, I've finally made some progress by employing the Ruby OAuth gem, and following the tutorial here: http://everburning.com/news/google-an...
Can I somehow use this
settings = {
'user1' => { 'path' => '/','days' => '5' },
'user2' => { 'path' => '/tmp/','days' => '3' }
}
in a external file as settings?
How can I include this into my script?
...
I want to capture packets whoes has a special target ip, then forward these packets by UDP. Does Ruby can do this ? thanks
...
Is it possible to access a local HSQL database from Ruby as well as from Java? (separately of course, not concurrent) The Ruby SQL toolkit called Sequel, for example, claims to have "adapters" for JDBC, so I think the answer is yes, yes? =)
If the answer is "kind of" or something, is there a better RDBMS that would allow straightforward...
At the moment I'm using this regex to extract the video id from a Youtube URL:
url.match(/v=([^&]*)/)[1]
How can I alter this so that it will also get the video id from this Youtube URL, which has no v parameter:
http://www.youtube.com/user/SHAYTARDS#p/u/9/Xc81AajGUMU
Thanks for reading.
EDIT: I'm using ruby 1.8.7
...
I'd like to write a code beautifier and i thought of using Ruby to do it. Could someone show me a place to get started? I've seen a lot of code beautifiers online but I've never come across any tutorials on how to write one. Is this a very challenging task for someone who's never undertaken any projects such as writing a compiler, parser...
This URL takes you to an image, but has no file extension to check a regex against:
http://www.tonymooreillustration.com/gallery/main.php?g2_view=core.DownloadItem&g2_itemId=393
I'm using Restclient (HTTP and REST client for Ruby) in my app, so I tried doing this:
RestClient.get "http://www.tonymooreillustration.com/gallery/main....
I am trying to create an program similar to ELIZA. My preference is to implement this project in a general language such as ruby, java, C++.
is there some framework (open source would be great) available for any of these languages ?
...
Say I have a class with many attributes but need only one attribute at a time, i.e.
class A
attr_accessor :name
attr_accessor :other1
attr_accessor :other2
attr_accessor :other3
attr_accessor :other4
end
And want the output of only one attribute at a time:
a = A.new
puts a.name.to_str
to be:
...
Possible Duplicates:
i = true and false in Ruby is true?
What is the difference between Perl's ( or, and ) and ( ||, && ) short-circuit operators?
Ruby: difference between || and 'or'
Is || same as or in Rails?
Case A:
@year = params[:year] || Time.now.year
Events.all(:conditions => ['year = ?', @year])
will produce ...
I have this data and as you can see I have about 10 requests. A request has a venue, song, date and artist. I need to loop those requests and if there is are two request with the same song made to the same venue and date then i need to add then to a checkbox. For example:
#<Request id: 8, artist: "Metallica", song: "Turn the Page", venu...
I've been using the acts-as-taggable-on for tagging in my development app, but when I push it to Heroku, I get a nasty error:
ActionView::TemplateError (PGError: ERROR: relation "tags" does not exist
: SELECT tags.*, taggings.tags_count AS count FROM "tags" JOIN (SELECT taggings.tag_id, COUNT(taggings.tag_id) AS tags_count FROM "taggi...
I'd like to start with Ruby/Tk on Linux, but the default included styles are not very good looking...
I've seen screenshots of applications using Tile and looking great, so I'd like to know whether there is a collection of Tile themes somewhere (I would like something that looks like the GTK Clearlooks theme)?
I spent a lot of time goog...