Is there a better way than the following to check to see if a string is nil OR has a length of 0 in Ruby?
if my_string || my_string.length == 0
return true
else
return false
In C# there's the handy
string.IsNullOrEmpty(myString)
Anything similar to that in Ruby?
...
Hello,
I work at a small company and our production system uses a hand-rolled RESTful API, implemented in Java with JAXB. We now find that we're taking on customers who use Ruby on Rails, and I have to come up with a reference implementation to show customers how to use our API in Ruby. I'd love to be able to just tell them to use Acti...
I am a .net developer who would like to learn more about Ruby on Rails. I have followed the 5-minute(?!) marketware tutorials, etc, out on the rails site, but would like to learn more by reading real live code.
So what's the best open source resource for learning about RoR in depth?
EDIT: A slight clarification, I am a .net developer ...
I have been hearing a lot about Ruby and possibly even Javascript being "true" object oriented languages as opposed to C++ and C# which are class oriented (or template based) languages. What is meant by true OO and what are the advantages of this over the class/template approach?
...
Does anyone know of any specific DSL implementations used to import legacy Oracle database schemas. I have tried to just run db:schema:dump on my existing db I want to port to a new ruby app. However, the rake dies about halfway through with out any error. It kinda just locks up. I started looking for the best way to tackle this and foun...
Hello, this is probably a newbie ruby question. I have several libraries and apps that I need to deploy to several different hosts. All of the apps and libs will share some common settings for those hosts-- e.g. host name, database server/user/pass, etc.
My goal is to do something like:
cap host1 stage deploy
cap host2 stage deploy
cap...
How do I go about calling a method on state change in AASM?
I'd like to call update_foo when the state transitions to paid in the following model:
class Foo < ActiveRecord::Base
include AASM
# State Machine
aasm_initial_state :incomplete
aasm_state :incomplete
aasm_state :paid
aasm_event :pay do
transitions :from => :...
I'm having trouble getting a rails app on Dreamhost's Passenger to see compiled libraries in my ~/opt/lib directory. I have to put them here because I don't have root access.
I can boot up my app in ./script/console and it sees them libraries just fine because I updated my .bash_profile's LD_LIBRARY_PATH environment variable to inclu...
I have a CSV data file with rows that may have lots of columns 500+ and some with a lot less. I need to transpose it so that each row becomes a column in the output file. The problem is that the rows in the original file may not all have the same number of columns so when I try the transpose method of array I get an `transpose': elemen...
Really simple question - how do I do a search to find all records where the name starts with a certain string in ActiveRecord. I've seen all sorts of bits all over the internet where verbatim LIKE SQL clauses are used - but from what I've heard that isn't the 'correct' way of doing it.
Is there a 'proper' Rails way?
...
I have a command line Ruby app I'm developing and I want to allow a user of it to provide code that will run as a filter on part of the process. Basically, the application does this:
read in some data
If a filter is specified, use it to filter data
process the data
I want the filtering process (step 2) to be as flexible as possible....
I am using the following code to check if a variable is not nil and not zero
if(discount != nil && discount != 0)
.
.
.
end
Is there a better way to do this?
...
is there any good Ruby audio libraries that we can build upon?
Need to manage/edit mp3 files!!!
...
I'm looking for a way to supply an argument to a ruby on rails project at runtime. Essentially, our project uses public key cryptography to encrypt some sensitive client data and we want the ability to supply the password to the private key file at runtime.
...
Mac's have TextMate as there preferred application for ruby development, but what would be the preferred application for linux? I need something where it's easy to work with multiple files, project structure and setup commands to run my ruby app or if it is one my merb app.Syntax highlighting is also a must.
Now I typically use Vim, but...
What's the difference between a string and a symbol in Ruby and when should you use one over the other?
...
I have a app that I'm deploying to a development server using Capistrano. I'd like to force this deployment to use the development database. So far the only way I've managed to do it is to make my production database info in database.yml equal to the development info. But this is a complete hack.
I've tried setting rails_env to devel...
So I've got a Ruby method like this:
def something(variable, &block)
....
end
And I want to call it like this:
something 'hello' { do_it }
Except that isn't working for me, I'm getting a syntax error. If I do this instead, it works:
something 'hello' do
do_it
end
Except there I'm kind of missing the nice look of it being on ...
I am trying to insert an image (jpg) in to a word document and the Selection.InlineShapes.AddPicture does not seem to be supported by win32old or I am doing something wrong. Has anyone had any luck inserting images.
...
I'm struggling with Test::Unit. When I think of unit tests, I think of one simple test per file. But in Ruby's framework, I must instead write:
class MyTest < Test::Unit::TestCase
def setup
end
def test_1
end
def test_1
end
end
But setup and teardown run for every invocation of a test_* method. This is exa...