I am writing my own blog (every one should, it's good experience). I have implemented Atom and RSS feeds, and they are used by a number of readers. Most of those readers are using Google Reader, who at the moment polls my site regularly for updates.
I would like to setup a publish Subscribe (PubSubHubbub) option as documented here, an...
i'm trying to create a raw sockets using ruby .... the problem is there isn't any thing called raw socket there ,and on the other hand the socket class itself is not fully documented .... do any body have some code samples for that kind of sockets in ruby ?? or maybe some kind of a documentation for that ???
By the way i already know ve...
Now about 2 weeks into learning Ruby and Rails, I've found myself using the File class a lot for things like File.join, File.open, etc. Then I bumped into a need for File.copy only to find out that no such method exists. A little more looking uncovered Rails' FileUtils class and now I'm a little confused.
There are differences, of cours...
I am using rails 2.3.3 and ruby 1.9.1.
I am trying to render a view that includes a partial. In the partial i output a field of a model that is encoded in UTF8.
This fails with
ActionView::TemplateError (incompatible character encodings: ASCII-8BIT and UTF-8) on line #248 of app/views/movie/show.html.erb:
245: <!-- Coloumn right | s...
Hi. I am trying to write a simple program that takes a rgb value and changes the background to that color using Shoes (Raisins revision 1134). Here is my code:
Shoes.app :title => "Show a Color" do
def convert_to_num(value)
# Splits string into numerical values
value.split(',').map { |num| num.to_i }
end
def t...
I have a model which uses acts-as-tree. For example:
class CartoonCharacter < ActiveRecord::Base
acts_as_tree
end
Acts as tree has these associations:
class ActsAsTree
belongs_to :parent
has_many :children
end
From script/console I am building my tree, saving nothing until the entire tree is constructed. The trouble I am ha...
I have just started learning ruby on rails and I have encountered code like below:
class Post < ActiveRecord::Base
validates_presence_of :title
belongs_to :user
end
There are two method calls inside the class body.
I have had a hard time finding any ruby documentation that
describes how method calls from within a body of a class (...
I've loaded the cucumber.vim files into ftplugin and the other directories per instructions, but I don't understand the ftplugin syntax enough to figure out how to get the full benefits.
From what I can tell, the plugin is supposed to be able to jump between step definitions and feature files, but I can't figure out what's wrong with my...
I have an old function that is called many times in my application. I would like to update it a bit, which involves adding some new arguments.
When I wrote the function, I did not understand the benefits has making a hash the only parameter (mentioned here: http://www.skorks.com/2009/08/more-advanced-ruby-method-arguments-hashes-and-bl...
Hello all,
I'm having trouble editing an XML file. I'm currently trying to use Nokogiri, but I'm open to any other Ruby library to solve this problem.
I'm trying to add a Node set inside another node set. Both have some interesting namespacing. Here's the code. I'm trying to add the new_node to the parent right after the first <p:sp>
...
I am a newbie to Rails. I have simply scaffolded a small model. The model has a field called category. Now I want to filter the entries on the index page by category.
<% form_for @domain do |f| %>
<p>
Domain:
<%= f.select(:Domain,%w{ LifeStyle Automobiles FoodAndBeverage Health IT Telecom EntertainmentAndCelebrity Education BankingInv...
Hi I am new to Ruby and I am trying to learn Rails. I do not understand the use of the question mark (?) in Ruby.
Sometimes appears like this:
assert !product.valid?
sometimes I saw it in an if construct.
Could you tell me its meaning?
...
Which is the Recommended File Extension for rails view pages(2.3.2)
1.RHTML
2.html.erb
any significance in this.
...
I'm getting numbers like
2.36363636363636
4.567563
1.234566465448465
10.5857447736
How would i get ruby to round these numbers up (or down) to the nearest 0.05?
Thanks
...
I need to have 2 (or maybe 3) continuously running "facets" of a program in Ruby - a communications thread, a render thread and maybe a caching thread.
The idea is the rendering thread shows a slide-show (whose definition is read from file) and all slides are retrieved from a remote HTTP server by the communications thread. The renderi...
I am eager to know about any website testing software which is good in usability and look and feel.
Here are the main areas that software should cover.
1. Find the image size.
2. To check broken links.
3. Loading time of website.
4. Test the load with many virtual users.
5. Check for useless codes placed in the source code.
In short, I ...
Do you know a library to access system resources for Ruby? I would like to monitor CPU, disk, RAM, network...
I would be great to have a library to monitor not only Linux, but even FreeBSD, Windows, Solaris and Mac.
...
Sorry, this might be a basic/stupid/noob question - I am just trying to tweak an existing Ruby script - it runs on my Mac ok, but failing to run on Ubuntu 9.04.
The error is this:
/usr/lib/ruby/1.8/rss/rss.rb:922:in `have_required_elements?': undefined method `have_required_elements?' for "App Store Reviews for ":String (NoMethodError)...
I want to create a filter, and be able to apply it to an array or hash. For example:
def isodd(i)
i % 2 == 1
end
The I want to be able to use it like so:
x = [1,2,3,4]
puts x.select(isodd)
x.delete_if(isodd)
puts x
This seems like it should be straight forward, but I can't figure out what I need to do it get it to work.
...
I have a thread in Ruby. It runs a loop. When that loop reaches a sleep(n) it halts and never wakes up. If I run the loop with out sleep(n) it runs as a infinite loop.
Whats going on in the code to stop the thread from running as expected?
How do i fix it?
class NewObject
def initialize
@a_local_var = 'somaText'
end
...