ruby

How do I handle data which must be persisted in a database, but isn't a proper model, in Ruby on Rails?

Imagine a web application written in Ruby on Rails. Part of the state of that application is represented in a piece of data which doesn't fit the description of a model. This state descriptor needs to be persisted in the same database as the models. Where it differs from a model is that there needs to be only one instance of its class a...

no respond_to block in edit action (generated with scaffold)?

Does anyone know why there is no respond_to block for generated edit actions? Every other action in typical scaffold controllers has a respond_to block in order to output html and xml formats. Why is the edit action an exception? I'm using the latest version of Ruby on Rails (2.1.1). ...

Is Ruby any good for GUI development?

I am considering creating a GUI-based tool that I want to be cross-platform. I've dismissed Java, as I personally do not like Swing. I'm currently considering C# and using Mono to make it cross-platform. However I'm wondering whether new-fangled cross-platform languages like Ruby can offer me a decent GUI development environment. ...

Uploading files in Ruby on Rails

I have a web application that needs to take a file upload from the user and upload it to a remote server. I can take input from user to server fine via file_field, but can't seem to work out the next step of uploading from server to remote. Net::HTTP doesn't do multipart forms out of the box, and I haven't been able to find another goo...

Is there a way to dump the objects in memory from a running ruby process?

Killing the processs while obtaining this information would be fine. ...

How Do You Clear The IRB Console?

How do you clear the IRB console screen? ...

Why am I getting a "wrong number of arguments (0 for 2)" exception in my Ruby Code?

I'm trying to polish up my Ruby by re writing Kent Beck's xUnit Python example from "Test Driven Development: By Example". I've got quite far but now I get the following error when I run which I don't grok. C:\Documents and Settings\aharmel\My Documents\My Workspace\TDD_Book\TDDBook_xUnit_RubyVersion\lib\main.rb:21:in `test_running': w...

Getting started with rails? Must have gems?

I'm starting work on a project using Rails, but I'm waiting for the 3rd edition of the pragmatic rails book to come out before I purchase a book. Anyway, my question is a bit more pointed than how do I get started... What are some of the must have gems that everyone uses? I need basic authentication, so I have the restful authenticati...

Rails Tests Fail With Sqlite3

Hello all, I seem to be getting a strange error when I run my tests in rails, they are all failing for the same reason and none of the online documentation seems particularly helpful in regards to this particular error: SQLite3::SQLException: cannot rollback - no transaction is active This error is crippling my ability to test my appl...

Ruby and WS-Security

I'm having troubles finding good Ruby libraries that implement WS-Security. I've seen wss4r but have yet to use it (and the documentation is a bit light on it). What libraries do you use for this task, or is there a better alternative? ...

Which PHP framework is closest to Ruby on Rails? CakePHP? CodeIgniter?

I'm going to be switching back and forth between Ruby on Rails projects and some as-of-yet undecided PHP MVC framework projects. Which of the PHP MVC frameworks out there (CakePHP, CodeIgniter?, others?) is most similar to Ruby on Rails in that the most conventions, locations, workflows, etc are preserved? I'm looking for the similar...

How do I clear the cache of Ruby Phusion Passenger in Ubuntu?

I've tried restarting apache and the cached pages still appear, so there must be a folder someplace. I don't have a 'public/cache', so what other places should I look? Is there a URL flag that could trigger this effect as well? ...

What's the best way to implement ACLs to a Rails application?

I just wanted to compare different solutions used when implementing ACLs in Rails. ...

gsub partial replace

I would like to replace only the group in parenthesis in this expression : my_string.gsub(/<--MARKER_START-->(.)*<--MARKER_END-->/, 'replace_text') so that I get : <--MARKER_START-->replace_text<--MARKER_END--> I know I could repeat the whole MARKER_START and MARKER_END blocks in the substitution expression but I thought there should...

How do I generate a list of n unique random numbers in Ruby?

This is what I have so far: myArray.map!{ rand(max) } Obviously, however, sometimes the numbers in the list are not unique. How can I make sure my list only contains unique numbers without having to create a bigger list from which I then just pick the n unique numbers? Edit: I'd really like to see this done w/o loop - if at all pos...

What does 'yield called out of block' mean in Ruby?

I'm new to Ruby, and I'm trying the following: mySet = numOfCuts.times.map{ rand(seqLength) } but I get the 'yield called out of block' error. I'm not sure what his means. BTW, this question is part of a more general question I asked here. ...

Catching line numbers in ruby exceptions.

Consider the following ruby code test.rb: begin puts thisFunctionDoesNotExist x = 1+1 rescue Exception => e p e end For debugging purposes, I would like the rescue block to know that the error occurred in line 4 of this file. Is there a clean way of doing that? ...

Rails performance analyzers

What are the preffered plugins for monitoring and analyzing the performance of a Rails app? I'm looking for both database/query analyzers and the rest of the stack if possible, though not necessarily all in one plugin. Which ones do you recommend? ( Bonus points for free ones :) For example, this one looks spify. ...

User Monitoring in Rails

Hi We have an app with an extensive admin section. We got a little trigger happy with features (as you do) and are looking for some quick and easy way to monitor "who uses what". Ideally a simple gem that will allow us to track controller/actions on a per user basis to build up a picture of the features that are used and those that ar...

What are the steps needed to create and publish a rubygem of your own?

So you've created a ruby library. How do you create and publish your rubygem? And what common pitfalls and gotchas are there pertaining to creating and publishing rubygems? ...