I am trying to write a capistrano task that will backup databases on multiple servers. The bash script that backs up the databases is on my local machine. However capistrano outputs this error message:
`backup' is only run for servers matching {}, but no servers matched
I am new to capistrano, is there some kind of setting I can set s...
I want to increase the throughput of a script which does net I/O (a scraper). Instead of making it multithreaded in ruby (I use the default 1.9.1 interpreter), I want to launch multiple processes. So, is there a system for doing this to where I can track when one finishes to re-launch it again so that I have X number running at any time....
I'm pulling data from a feed that I have no control over and I need to verify if a string I'm given is a valid time.
Most of the time I'm correctly sent something like "2:35" or "15:41" but other times it's things like "AM" or "PM" (and no numbers)...so I ultimately just need to ignore those.
So, how can I verify if the data is a valid...
Hello,
Let's say I have a class named Klass, and a class called Klass2. Depending on the user's input, I'd like to decide whether I'll call "hello_world" on Klass, or Klass2:
class Klass
def self.hello_world
"Hello World from Klass1!"
end
end
class Klass2
def self.hello_world
"Hello World from Klass2!"
end
end
input =...
I have the following controller test case:
def test_showplain
Cleaner.expect(:parse).with(@somecontent)
Cleaner.any_instance.stubs(:plainversion).returns(@returnvalue)
post :showplain, {:content => @somecontent}
end
This works fine, except that I want the "stubs(:plainversion)" to be an "expects(:plainversion)".
Here's the co...
I have a drop down list of Type in my Products model.
I want to be able to search in the Products index.html.erb so a user selects a type from a drop down list, clicks search and all the products matching that type are returned.
I can get normal search methods working where the user enters in their search in a text box but I cannot get ...
What I'm trying to do is make a basic flashcard app on rails. At this point, all I'm looking for is the functionality to iterate through a list of flashcards, quiz the user and let the user know if they were right or not. In ruby, it didn't take me long to write:
class Card
attr_accessor :answer, :question
def initialize(answer = ...
That's pretty much it. I'm using Nokogiri to scrape a web page what has ; characters in it, and I can't figure out how to do the conversion. here's what I tried:
str.gsub(/’/,"'")
str.gsub("’","'")
str.gsub("ΓÇÖ","'") # that's how it looks when I do a puts
(In the above, there's no space between the and the ";", bu...
I manually placed a library in the library directory (/usr/local/lib/ruby/site_ruby/1.8) and when I try to require it, it says "no such file to load".
I used "$:.first" to get the library path, so why wont it work? Is there any good way to debug this?
Thanks
...
Hi, I'm new to rails and I'm trying to make a help page that just lists questions and answers. Currently I have something very simple like this :
<% @helps.each do |help| %>
<%=h help.category %>
<%=h help.question %>
<%=h help.answer %>
<% end %>
Along with each question and answer is a category they belong to. How do i create a drop...
I am implementing a betting system and each user has a balance , how can i find a rank of a user using activerecord methods?
thanks for your help.
...
I'm running into a little hiccup with my AJAX creation of comments for posts. Everything works great but I am doing this in the index.html.erb view so the create.js.erb is finding the first div that says "comments" and inserting the comment there.
I know how to create a post specific div by using:
<div id="comments_<%= post.id %>
B...
Inside a ruby script, how do I get the path to the ruby interpreter?
Example script:
#!/path/to/ruby
puts `#{RUBY_INTERPRETER_PATH} -e "puts 'hi'"`
#EOF
Where RUBY_INTERPRETER_PATH is a mythical way of finding /path/to/ruby.
This is just an example, though. I realize in this case that I could just copy /path/to/ruby into the s...
I just tried the ruby-graphwiz gem (http://github.com/glejeune/Ruby-Graphviz). I followed the instructions (installed Graphwiz, gem and dependencies) and tried the example from the Github page. Unfortunately I am not able to render any output image (png,dot).
# Create a new graph
g = GraphViz.new( :G, :type => :digraph )
# Create two n...
I am using the following code to check existence of a file before publishing an image in my erb file. This is a ruby/sinatra app - not rails.
<% @imagename = @place.name + ".jpg" %>
<% if FileTest.exist?( "/Users/Tim/projects/game/public/" + @imagename ) %>
<p><img src= '<%= @imagename %>' width="400" height="300" /> </p>
<% end %> ...
This is a large commit. But I want you to concentrate on this change block. http://github.com/rails/rails/commit/d916c62cfc7c59ab6411407a05b946d3dd7535e9#L2L1304
Even without understanding the full context of the code I am not able to think of a scenario where I would use
include Module.new {
class_eval <<-RUBY
def foo
pu...
I've just noticed that a lot of hpricot code is written in java...
I heard that JRuby performed a lot better than native ruby when processing regular expression. Is maybe the java classes just activated if JRuby or Java is installed and the ruby used if these are not found?
It's something puzzling indeed.
Thanks
...
I have a few DRb services running on different windows machines and they can all connect and talk with each other just fine. When I put these DRb services on Linux machines and try to connect from windows nothing happens and I get a DRB:ConnError ... the service on Linux is never touched. So I did a netstat on the linux box and the servi...
I have a string called 'raw'. I am trying to parse it in ruby in the following way:
raw = "HbA1C ranging 8.0—10.0%"
raw.scan /\d*\.?\d+[ ]*(-+|\342\200\224)[ ]*\d*\.?\d+/
The output from the above is []. I think it should be: ["8.0—10.0"].
Does anyone have any insight into what is wrong with the above regex statement?
Note: \342...
I've installed the development version of Crunchbang, a linux distro based off Debian. I got Ruby and Rubygems installed, but I can't get the gems I've installed to load. Here is a command-line session:
$ ruby -v
ruby 1.9.1p378 (2010-01-10 revision 26273) [i486-linux]
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.6
...