ruby

Ruport vs. Prawn considering long-term use

I want to add reporting capabilities to my Rails application and I'm struggling quite some time now on which reporting software to use to create my PDF documents. Until now I'm pretty sure that either Ruport or Prawn are the best way to go. After experimenting with both of them I find that they both are very powerful and quite universa...

updating wrong value to database

Hey all, I'm just trying to increment a record by 1 starting at 2000, when a new record is created upon clicking on the create action to create a record: if resource_model == Student then @resource.testing_id = id + 2000 end So if the record has an id of 1, I assume that the testing_id will be 2001. But instead it returns: 2147483647 ...

Is there a Ruby equivalent for the typeof reserved word in C#?

I have a C# method that I need to call from a piece of Ruby that requires a System.Type argument. Is there a Ruby equivalent to typeof in C#? The call will look something like this in C# ... var CustomClasInstance = Container.GetInstance(typeof(ICustomClass)) ...

restful authentication and LDAP

Hi, I'm new on ruby, i use the restful authentication plugin and that works perfectly, Now, i have an authentication based on LDAP, and i want to combine ldap and restful authentication. Ldap also Any examples ? Thank you for help. ...

ruby - how to encrypt text

Hi, I need to encrypt a string (from a text area) that will also be decrypted later on when it is displayed. I'm not to concerned about it being majorly secure, but just don’t want to store the data in plain text format. Does anyone have any suggestions on how to do this easily in rails? Thanks, Jon ...

Compare and contrast the Ruby ORMs (Sequel, DataMapper and ActiveRecord)

Please compare their strengths and weaknesses. ...

Overriding method calls in Ruby?

I'm trying to get a callback when any method on a particular class is called. Overriding "send" doesn't work. It seems send doesn't get called in normal Ruby method invocation. Take the following example. class Test def self.items @items ||= [] end end If we override send on Test, and then call Test.items, send doesn't get call...

Can I learn Haml and Sass even if I don't know Ruby?

I downloaded Haml from here: http://rubyforge.org/frs/?group_id=2760. When I extract the zip there are a bunch of .rb files and the official web page talks about gems. I think this is some Ruby stuff. Can I learn Haml and Sass even if I don't know Ruby? If I have to, how do I install all this on Windows XP? ...

Why is class_inheritable_reader in ActiveSupport not documented?

Hi there, Pulling my hair out trying to figure out where class_inheritable_reader is documented in Rails. A Google search revealed its existence, and looking in the gem itself ya find the method: def class_inheritable_reader(*syms) syms.each do |sym| next if sym.is_a?(Hash) class_eval <<-EOS def self.#{sym} ...

Process.daemon vs. running a Ruby script with nohup + &

I have a Ruby 1.9 script that I want to run as a long-running background process. It looks like I have a choice between calling Process.daemon inside the script to daemonize it, or I can just run the script in the background using a shell's ampersand and keep it running after I log out of the server by prefixing the command with nohup....

Ruby : How to write a gem ?

I'd like to write a package for Ruby and make it available as a gem. What are the tools, steps and pitfalls ? Are there any good tutorials, screencasts, etc., which helped you learning how to do it ? ...

Error installing Rails (after installing nearly 20 dlls one by one) rl_attempted_completion_over (readline.dll)

Each time I typed: gem install rails it asked me for a dll. SO I downloaded the following: datasvcs.dll, icudt24l.dll, icuin24.dll, icuio24.dll, icuuc24.dll, libeay32.dll, libmex.dll, libmwservices.dll, libmx.dll, libut.dll, libz.dll, mpath.dll, msvcrt-ruby191.dll, mvalue.dll, m_dispatcher.dll, nscrt.dll, readline.dll, sslea...

Is it Possible to achieve Multiple Inheritence in ruby?

I have doubt whether we can achieve multiple inheritence using 'module' concept or Is there any other keywords or concepts which achieve multiple inheritence in ruby? ...

Why doesn't this escape character actually work in Ruby?

code: file.write 'objectclass: groupOfUniqueNames\n' Oddly enough, the \n is actually being printed... What is wrong here? ...

log doesn't work in production with delayed job

I'm suffering some weird issue where my delayed_jobs are failing in production. Finally I narrowed it down to the logger. If I comment out my log function calls, everything works. However if I try to log, I get this in the delayed_job handler: --- !ruby/struct:Delayed::PerformableMethod object: AR:User:1 method: :load_and_update_wi...

Writing Beautiful Ruby: Checking for nil string before concatenating

Currently I have: file.puts "cn: " + (var1.nil? ? "UNKNOWN" : var1) Which works fine, but doesn't look good. What is a better way to write this in ruby so that I am checking for nil and not concatenating it Note: This question is similar to a LOT of questions, but in no such way is it anything of a duplicate. This question is about s...

Memcached rubygem + Rlibmemcached argument error with memcache_mget()

I am getting an exception when using Evan Weaver's Memcached gem (as Memcached::Rails.new) -> (http://github.com/fauna/memcached) and calling get_multi() ArgumentError: wrong # of arguments(2 for 4) from /usr/local/lib/ruby/gems/1.8/gems/memcache-auth-1.0.1/lib/memcached/memcached.rb:384:in `memcached_mget' from /usr/local/lib/ruby/gems...

Why use a nested Ruby module for version information?

I've been looking at the source code of a few gems lately. One idiom that I keep seeing is the use of a nested module containing version constants that are joined into a version string i.e. variations around this sort of thing: module ChunkyBacon module Version MAJOR = 0 MINOR = 6 TINY = 2 end VERSION = [Version::MAJ...

Why would using File.open call once result in it being called 3 times according to rspec

Below you can see that I'm calling File.open only once but rspec is telling me it received it 3 times. def self.import_file(filename) current_file = filename.split('/').last destroy_all(["filename = ?",current_file]) unpack_format = "A#{INPUT_FILE_FORMAT.map{|element| element[1]}.join("A")}" debugger File.open(filename, 'r')....

Including large JS library with :cache => true into a rails app

Hi, I am thinking about the best way of including a JS library into rails app supporting :cache => true option for both JS and CSS. Let me take an example to describe the question: jQueryUI (that's just an example). It usually has the following structure when downloaded: +jq.ui +css +skin1 +images all_...