I am a beginner to Ruby. I've heard the following complaints about Ruby, and was hoping the Stack Overflow community could address each point raised.
Common complaints about Ruby that I've heard:
Ruby is slower than Java
Ruby is not statically typed
It's not suitable for large projects
Given these admittedly opinion based statement...
I have merb setup but when I try to run it I get issue with any gems I try to include, e.g. I have the following:
require 'RMagick'
The rmagick gem is installed, and doing the above in irb (after requiring rubygems works as expected) even putting require 'rubygems' before I require RMagick doesn't fix the issue.
...
I have simple model which looks like this:
def video_file=(input_data)
unless input_data.to_s.empty?
newfile = File.open("#{RAILS_ROOT}/public/to_upload/#{self.filename}_vid.f4v", "wb") do |f|
while buff = input_data.read(4096)
f.write(buff)
end
end
end
end
and here the error which rails manages to disp...
Is there an easy way to create Word documents (.docx) in a Ruby application? Actually, in my case it's a Rails application served from a Linux server.
A gem similar to Prawn but for DOCX instead of PDF would be great!
...
I have some modules where I would like to use instance variables in. I'm currently initializing them like this :
module MyModule
def self.method_a(param)
@var ||= 0
# other logic goes here
end
end
I also could call a init method to initialize them :
def init
@var = 0
end
but this would mean I have to remember to alw...
Hi there. I have a small problem.
How to create a link of this type:
a href="#" onClick="document.getElementById('search').value=this.value"
using method 'link_to' in Rails?
P.S. I write http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html, but I can not imagine how to make such a link.
...
I have created a blog, it will have posts, and the posts are created by the users. I already have a login system in my blog. And I have made the relation between a user and his posts. Now when I want to add a new post I want Rails to autofill the user_id field.
Should I add a hidden field and add the user_id from the session where I sav...
Hello, I have a form which spans multiple pages. The way it is set up now is not ideal because it saves (to the database) each page when it is submitted. So if the user does not complete the form across all pages there would be an incomplete user registration saved in the database.
I would like to 'rollback' the saves if the user doesn'...
I have access to ruby's exception hierarchy (it's mentioned in both the pickaxe and the hummingbird), but I'm not sure which exception to use because I haven't found any information on what each of the terms mean.
Does using the right exception class matter?
...
If I have two ranges that overlap:
x = 1..10
y = 5..15
When I say:
puts x.include? y
the output is:
false
because the two ranges only overlap partially.
But if I want it to be "true" when there is partial overlap between two ranges, how would I write that? In other words I need a way to know when one range contains a subset of...
I'm wondering if there's going to be be any big Ruby conferences coming up over the next few months? I'm in NY so I'm hoping there's going to be something close by.
...
i have a rails app must consume wcf services provided by asp.net, are there any ruby clients for wcf?
...
I have a string in a db that contains a local variable reference and I want Ruby to parse and replace it.
For example, the string in the db is "Hello #{classname.name}" and it is stored in classname.description
and my code reads:
<%=h @classname.description %>
Put that just prints the exact value from the db:
Hello #{name}
and not...
If you have polymorphic belongs_to associations then references will add both of the columns required:
create_table :products do |t|
t.references :attachment, :polymorphic => {:default => 'Photo'}
end
will add an attachment_id column and a string attachment_type column with a default value of ‘Photo’.
What, exactly, does this mean?...
Suppose I have a module with the methods : function1,function2,function3. I want to import function1 and function2 but not function3. Is there a way to do this in ruby?
...
I have a script written in ruby. I need to remove any duplicate newlines (e.g.)
\n
\n
\n
to
\n
My current attempt worked (or rather not) using
str.gsub!(/\n\n/, "\n")
Which gave me no change to the output. What am I doing wrong?
...
Hello all and thanks for your time reading this.
I need to verify certificates issued by my own CA, for which I have a
certificate. How can I do the equivalent to openssl's
openssl verify -CAfile
in Ruby code? The RDoc for OpenSSL is not very helpful in this regard.
I've tried:
require 'openssl'
ca = OpenSSL::X509::Certificate.ne...
I'm not entirely sure how to post this question, but here goes...
I have a web app that has a list of sortable items. I sort them ajax style using Sortable. That works like a charm. I can drag and drop the items till my heart is content.
At the same time, there is a button that allows for the creation of new items on my list. This ...
I'm on OS X (with bash) and a newbie at unix. I want to know if it's possible to amend some file such that to run a ruby program, I don't need "ruby file.rb", but instead can just run "ruby.rb".
Is there a reason NOT to do this?
Thanks!
...
I asked a question yesterday about comparing ranges for overlap and its been stuck in my throat ever since.
The consensus seems to be that my preferred answer which involves using the array intersection operator (&), is inefficient because comparing arrays is costly.
I wonder then, why this feature is in the language? Could it be that ...