I am trying to sending XML content through POST to a controller ('Parse') method ('index') in a simple Rails project. It is not RESTful as my model name is different, say, 'cars'. I have the following in a functional test that works:
def test_index
...
data_file_path = File.dirname(__FILE__) +
'/../../app/views/layouts/in...
Say I have the following hashes:
hash_x = {
:a => 1,
:b => 2
}
hash_y = {
:b => 2,
:c => 3
}
I need a chunk of logic that compares the two for equality only taking into consideration intersecting keys.
In this example the 'b' key is the only commonality between the two hashes and it's value is set to '2' in both so by that ...
I'd like to know how much took to run the 10 most time consuming tests.. like I can do with rspec, any suggestion?
...
I am trying to setup a simple UDP client and server using Ruby. The code looks like this:
require 'socket.so'
class UDPServer
def initialize(port)
@port = port
end
def start
@socket = UDPSocket.new
@socket.bind(nil, @port) # is nil OK here?
while true
packet = @socket.recvfrom(1024)
puts packet
en...
I'd like to do something like this:
some_method.should_raise <any kind of exception, I don't care>
How should I do this?
some_method.should_raise exception
... doesn't work.
...
So I have this app
require 'tk'
class Foo
def my_fancy_function
puts "hello, world!"
end
def initialize
@root = TkRoot.new{title "Hello, world!"}
frame = TkFrame.new
my_fancy_button = TkButton.new(frame) do
text "Press meee"
command {my_fancy_function}
pack
end
frame.pack
Tk.mainloop
...
I have problem with STI and relationship in ActiveRecord. I think I missed something in the class methods, but I don't know for sure. Below is my models:
class User < ActiveRecord::Base
has_many :advertisements
end
class Advertisement < ActiveRecord::Base
belongs_to :user
end
class FreeAdvertisement < Advertisement
end
class Paid...
In Ruby on Rails, for conditions, it's easy to make SQL-injection-proof queries:
:conditions => ["title = ?", title]
where title comes from the outside, from a web form or something like that.
But what if you are using SQL fragments in other parts of the query, like:
:select => "\"#{title}\" AS title" # I do have something like th...
I am writing a web based debugger for Ruby, but in order to do this I need to be able to call the Ruby debugger from within a Ruby program on the server side. Has this ever been done? Is this even possible?
The end product being built will allow Ruby code to be edited, executed and stepped through using just a web browser. The ruby code...
I'm having issues with a site on my server loading and was running 'top' and saw this:
Dozens of ruby processes...and I have no idea what that means or if that's normal. :)
...
Hello all,
I am attempting to write a very simple rake task (and merge it into a rather large rake task) that will call the following command and pass in a randomly generated password. For the moment, let's even fake the random generation and just give it a set password of 'test':
createuser -SDPRE test
The code I have for my task is...
So I have two ruby Date objects, and I want to iterate them every month. For example if I have Date.new(2008, 12) and Date.new(2009, 3), it would yield me 2008-12, 2009-1, 2009-2, 2009-3 (as Date objects of course). I tried using range, but it yields every day. I saw step method for Date however it only allows me to pass number of days (...
"9.99".to_f
=> 999.0
Is this the expected behavior? How would one convert "9.99" to 9.99
...
What is the simplest way for transliteration of non English characters in ruby. That is conversion such as:
translit "Gévry"
#=> "Gevry"
...
Hello folks,
I'm writing web chat application, similar to GTalk. It based on Orbited + Sinatra for client side, and Ruby for server side. I've already implemented all the protocol, everything working good. But. I got a problem - dont know how to deal if there are multiple connections from one user. Let`s say for example, i logged to cha...
ruby somescript.rb somehugelonglistoftextforprocessing
is this a bad idea? rather should i create a separate flat file containig the somehugelonglistoftextforprocessing, and let somescript.rb read it ?
does it matter if the script argument is very very long text(1KB~300KB) ? what are some problems that can arise if any.
...
Hi,
All of the following API do the same thing: open a file and call a block for each line. Is there any preference we should use one than another?
File.open("file").each_line {|line| puts line}
open("file").each_line {|line| puts line}
IO.foreach("file") {|line | puts line}
...
I had trouble with the gem at first but got it to work when I installed the 64-bit MySQL and reinsatlled the gem with arch flags.
So it work in rails. The error I used to get was
uninitialized constant MysqlCompat::MysqlRes
but that is now gone :)
However in Xcode when I run a RubyCocoa project I still get the old error of
uninit...
What does this part . . .
unless Rakismet::Base.rakismet_binding.nil?
{ :referrer => 'request.referer', :user_ip => 'request.remote_ip',
:user_agent => 'request.user_agent' }.each_pair do |k,v|
data[k] = eval(v, Rakismet::Base.rakismet_binding) || ''
end
end
of the following method do?
module In...
I have 6 years of C# programming experience and I'm looking to broaden my horizons. I'm going to build a simple web app to demonstrate knowledge of Ruby on Rails so I can get my foot in a place that might want a Rails programmer. It's the hot new thing, so I want to be marketable.
Anyway, I have been playing around with solr and tomcat ...