I was wondering why smartphone/mobile device OSs are not written to allow dynamic languages as the language of choice? iPhone uses Objective-C, Google Android uses Java, Windows Mobile uses any manner of .NET language.
What would be the reasoning behind a mobile OS being written in Python, Ruby, or any other dynamic language? I unders...
How do you figure out what the older versions are for a particular Ruby Gem?
I need to revert to an older version of the rack gem but I'm not sure which versions are available.
...
I would like to use a lighter framework than Rails (Sinatra/Ramaze/Camping) but am concerned that by doing so I will not be able to use a lot of shared libraries that have been tailored to Rails in the form of plugins. Is this a major concern or are most of these plugins usable across different Ruby frameworks?
Are there any other poten...
I expected the following code to print "8", "111" and "999". I supposed that each a, b, c and d points to the same memory location. If I change the location through one of them, why would the other not to change? Clearly, my logic is poor, or I overlooked something. It prints "7", "7" and "8", instead.
Why?
a=b=c=d=7
b = 8
...
I have this block of code:
users = Array.new
users << User.find(:all, :conditions => ["email like ?", "%foo%"])
users << User.find(:all, :conditions => ["name like ?", "%bar%"])
users.flatten!
users.uniq!
puts users.to_json :include => [:licenses]
When I run it using script/console, it returns exactly what you would think it should, a...
I have a need for a model(?) on my app which basically contains a status of another entity. In the entity I want to store the id of the status, but in my app, the view is talking in terms of a nice word description. For instance, 1=New, 2=Used etc etc.
How can I go about implementing this in the best way that means I can easily set an...
Hi, I'm attempting to implement nested object forms for my site, using Ryan Daigle's blog post as a guide (http://ryandaigle.com/articles/2009/2/1/what-s-new-in-edge-rails-nested-attributes). For some reason, the nested form fields don't appear in the view.
class Instruction < ActiveRecord::Base
has_many :steps
accepts_nested_attri...
Is there a web site that indicates which gems work on rubinius (or other implementations of ruby), like isitruby19.com indicates which gems work on ruby 1.9? (I'm curious about heckle working with rubinius in particular)
...
I'd to get a person's age from it's birthday. now - birthday / 365 doesnt work, because some year has 366 days. I came up with following code:
now = Date.today
year = now.year - birth_date.year
if (date+year.year) > now
year = year - 1
end
Is there a more rubyish way to calculate age?
...
I'm using rake to copy a directory as so:
file copied_directory => original_directory do
#copy directory
end
This works fine, except when something inside of original_directory changes. The problem is that the mod date doesn't change on the enclosing directory, so rake doesn't know to copy the directory again. Is there any way to hand...
Say I have a string with comma delimited values enclosed in single quotes that may or may not include commas, like this:
"'apples,bananas','lemons'"
and I want to split that into an array
["apples,bananas", "lemons"]
Apparently, if I split(',') the string I get
[ "'apples", "bananas'", "lemons" ]
which I don't understand. The o...
Hello,
I would be thankful for any help on this:
I want to write an extension to my c library. I created file zmq.cpp that uses library libzmq (written in C++).
I created makefile using ruby extconf.rb, then I run nmake. It all went fine. Nmake generated files
librbzmq-i386-mswin32.def
librbzmq-i386-mswin32.lib
librbzmq-i386-mswin32...
I have a user and post model:
class User < ActiveRecord::Base
has_many :sent_posts, :class_name => 'Post'
end
class Post < ActiveRecord::Base
belongs_to :user
end
The problem is that in the console, if I do
User.first.sent_posts.empty?
it returns True.
But if I do this in my view
<%= @user.sent_posts.empty? %>
it returns F...
What's the smartest way to have Nokogiri select all content between the start and the stop element (including start-/stop-element)?
Check example code below to understand what I'm looking for:
require 'rubygems'
require 'nokogiri'
value = Nokogiri::HTML.parse(<<-HTML_END)
"<html>
<body>
<p id='para-1'>A</p>
<div clas...
Hi there,
I'm looking for a simple way to let users define a set of rules to filter objects.
Eg. let them define something like "notify me about a booking if booking date < 2009/04/30 AND value > 100.00"
More or less: I'd like to have a Ruby rules engine with custom DSL.
Is there a library offering that? Came across Ruleby, but it do...
I want to build a SOAP client using ruby. I tried using the soap4r library to generate ruby classes out of the WSDL file, but the issue with this was that all the methods it generated were of optional kind, instead of NAME/VALUE pairs. Given that some methods have a very large number of arguments, many of which are optional, I would pref...
I'm just starting to learn Rails. I created an empty Rails app. And instead of writing a Controller, I want to put all of my Controller logic in my Views instead of in separate Controller classes.
To do this, should I use .erb files or .rhtml files and what's the difference?
...
I am setting up an Apache2 webserver running multiple Ruby on Rails web applications with Phusion Passenger. I know that Passenger spawns Ruby processes for handling requests. I have the following questions:
If more than one request has to be handled at the same time, will Passenger spawn multiple processes or multiple (Ruby) threads? ...
I want to make CSV::Writer generate a line break within a quoted string:
A,B,"Line
Line",C
So that the row would display in Excel as:
A,B,Line,C
Line
Is it possible to prevent CSV:Writer from stripping out newlines?
If not, would switching to FasterCSV solve this problem?
...
I am relatively new to ruby, and I've been amazed with some of the Gems available. Sinatra comes to mind (one of the simplest ways to create working RESTful interfaces I've ever seen).
So I was wondering, what are some of the coolest or most amazing Gems my fellow programmers have found, that a newbie Ruby guy should look at. Im not l...