ruby

Being as DRY as possible in a Ruby on Rails App

I'm currently using the awesome attachment-fu plugin for a Rails app, but as a novice developer, I've never encountered a scenario like the one I've found myself in. Essentially, I'm using the attachment-fu plugin on two levels. The first is for user avatars in the user class. The second is to allow file attachments (PDFs, etc) in a mess...

Any tips on getting Rails to run with an Access back-end?

I shudder to ask, but my client might offer no other SQL (or SQL-like) solution. I know Access has some SQL hooks; are they enough for basic ActiveRecord? Later: I appreciate all the suggestions to use other databases, but trust me: I've tried convincing them. There is an "approved" list, and no SQL databases are on it. Getting some...

Is there a way to call a private Class method from an instance in Ruby?

Other than self.class.send :method, args..., of course. I'd like to make a rather complex method available at both the class and instance level without duplicating the code. ...

What is the difference between Ruby 1.8 and Ruby 1.9

I'm not clear on the differences between the "current" version of Ruby (1.8) and the "new" version (1.9). Is there an "easy" or a "simple" explanation of the differences and why it is so different? ...

Zemanta/Open Calais, how do they do that.

Hi, I was wondering how as semantic service like Open Calais figures out the names of companies, or people, tech concepts ,keywords etc from a piece of text. Is it because they have a large database that they match the text against? How would a service like Zemanta know what images to suggest to a piece of text for instance? Was hop...

How does Ruby 1.9 handle character cases in source code?

In Ruby 1.8 and earlier, Foo is a constant (a Class, a Module, or another constant). Whereas foo is a variable. The key difference is as follows: module Foo bar = 7 BAZ = 8 end Foo::BAZ # => 8 Foo::bar # NoMethodError: undefined method 'bar' for Foo:Module That's all well and good, but Ruby 1.9 allows UTF-8 source code. ...

Acts-as-readable Rails plugin Issue

I'm using Intridea's Acts as Readable Rails plugin for a messaging system I'm currently building. I've defined my message class accordingly: class Post < ActiveRecord::Base acts-as-readable end And everything seems to be working according to plan, but when trying to execute to show unread messages in my message view, I'm running int...

What's the best way to configure my Ruby compilation in Debian?

When compiling from source, I never know which configure flags to use to optimize the compilation for my environment. Assume the following hardware/OS: Single Core, 2 GHz Intel 512MB Ram Debian 4 I usually just go with ./configure --prefix=/usr/local Should I be doing anything else? ...

How can I graph the Lines of Code history for git repo?

Basically I want to get the number of lines-of-code in the repository after each commit. The only (really crappy) ways I have found is to use git filter-branch to run "wc -l *", and a script that run git reset --hard on each commit, then ran wc -l To make it a bit clearer, when the tool is run, it would output the lines of code of the ...

How do I marshall a lambda (Proc) in Ruby?

Joe Van Dyk asked the Ruby mailing list: Hi, In Ruby, I guess you can't marshal a lambda/proc object, right? Is that possible in lisp or other languages? What I was trying to do: l = lamda { ... } Bj.submit "/path/to/ruby/program", :stdin => Marshal.dump(l) So, I'm sending BackgroundJob a lambda object, which cont...

Setting Attributes in Webby Layouts

I'm working with Webby and am looking for some clarification. Can I define attributes like title or author in my layout? ...

Best Solution For Authentication in Ruby on Rails

I'm looking for a pre-built solution I can use in my RoR application. I'm ideally looking for something similar to the ASP.NET Forms authentication that provides email validation, sign-up controls, and allows users to reset their passwords. Oh yeah, and easily allows me to pull the user that is currently logged into the application. I...

Programming a simple IRC (Internet-Relay-Chat) Client.

I started using IRC at a young age, and I have always been fascinated with it. As a language exercise, I was thinking about programming a simple IRC client in Ruby with Shoes as a graphical front-end. My question to you, kind-sirs, what do I need to become familiar with to start on this great adventure (besides shoes and Ruby of course...

WYSIWYG editor gem for Rails?

Is there a good ruby gem for a WYSIWYG editor that will easily work with a rails app? ...

Ruby Performance

I'm pretty keen to develop my first Ruby app, as my company has finally blessed its use internally. In everything I've read about Ruby up to v1.8, there is never anything positive said about performance, but I've found nothing about version 1.9. The last figures I saw about 1.8 had it drastically slower than just about everything out th...

Is there a rake task for backing up the data in your database?

Is there a rake task for backing up the data in your database? I already have my schema backed up, but I want to make a backup of the data. It's a small MySQL database. ...

How do I gracefully shut down a Mongrel web server

My RubyOnRails app is set up with the usual pack of mongrels behind Apache configuration. We've noticed that our Mongrel web server memory usage can grow quite large on certain operations and we'd really like to be able to dynamically do a graceful restart of selected Mongrel processes at any time. However, for reasons I won't go into h...

Ruby / Rails pre-epoch dates on windows

Working with dates in ruby and rails on windows, having problems with pre-epoch dates (before 1970) throwing out of range exceptions. Tried using both Time and DateTime objects but continuing to have the same problems. ...

cannot install ruby gems - zlib error

I'm trying to install some Ruby Gems so I can use Ruby to notify me when I get twitter messages. However, after doing a "gem update --system", I now get a zlib error every time I try and do a gem install of anything. below is the console output I get when trying to install ruby gems. (along with the output from "gem environment"). C:\da...

Generating an object model in Ruby from an XML DTD

I have an XML document with a DTD, and would love to be able to access the XML model, something like this: title = Thing.Items[0].Title Is there a way, in Ruby, to generate this kind of object model based on a DTD? Or am I stuck using REXML? Thanks! ...