ruby-on-rails

What is the best practice for an environment based configuration file in Ruby on Rails

I have several properties that are dependent on the environment the application is running. For example, there are links to another application that is being developed concurrantly that get displayed in the header and footer. I want those links to be different depending on what environment they are in. This is slightly different than t...

How does theming for ziya charts work?

I'm implementing charts using The Ziya Charts Gem. Unfortunately, the documentation isn't really helpful or I haven't had enough coffee to figure out theming. I know I can set a theme using chart.add(:theme, 'whatever') Problem: I haven't found any predefined themes, nor have I found a reference to the required format. ...

Do callbacks stop operations in rails

If a callback handler returns false, does it cause only the handlers for that callback to not be called, or does it cause the remaining callbacks in that handler and all subsequent callbacks to not be called as well? ...

How do I 'validate' on destroy in rails

On destruction of a restful resource, I want to guarantee a few things before I allow a destroy operation to continue? Basically, I want the ability to stop the destroy operation if I note that doing so would place the database in a invalid state? There are no validation callbacks on a destroy operation, so how does one "validate" whethe...

How to do a rolling restart of a cluster of mongrels

Anybody know a nice way to restart a mongrel cluster via capistrano in a "rolling" style, eg, one mongrel at a time. Would be great to have a bit of wait time in there as well for each, to let the mongrel load the rails app up as well. I've done some searching, and haven't found too much, so looking for help before I dive into the mong...

Does anyone know of any cross platform GUI log viewers for Ruby On Rails?

I'm tired of using: tail -f development.log To keep track of my rails logs. Instead I would like something that displays the info in a grid and allows my to sort, filter and look at stack traces per log message. Does anyone know of a GUI tool for displaying rails logs. Ideally I would like a standalone app (not something in Netbeans...

Widget Data Across Multiple Controllers

Let's say that I have a widget that displays summary information about how many posts or comments that I have on a site. What's the cleanest way to persist this information across controllers? Including the instance variables in the application controller seems like a bad idea. Having a before filter that loads the data for each contr...

What is the best way to run asynchronous jobs in a Rails application?

I know there are several plugins that do asynchronous processing. Which one is the best one and why? The ones I know about are: BackgrounDRb ...

When do transactions start when using (restful) rails

Is it the case that the entire restful verb is under a single all encompassing transaction? That is to say, if I raise a Error in the validation or callbacks at any point in the handling of a UPDATE, DELETE, or CREATE operation, is every database operation that I may have performed in previous callbacks also rolled back? Succinctly, does...

SQL Server Adapter for Rails

Trying to find the sqlserver adapter for rails on windows. I have tried getting it from (without luck): gem install activerecord-sqlserver-adapter --source=http://gems.rubyonrails.org Where else can I get this gem? UPDATE: Make sure to run the command prompt as the administrator. Right click on the command prompt and click "Run as a...

Long running ruby process that uses ActiveRecord to store records in a database

I'm trying to write an app using Ruby on Rails and I'm trying to achieve the following: The app needs to receive UDP messages coming in on a specific port (possibly 1 or more per second) and store them in the database so that the rest of my Rails app can access it. I was thinking of writing a separate daemon that would receive th...

Best Way to Conditional Redirect?

Using Rails v2.1, lets say you have an action for a controller that is accessible from more than one location. For example, within the Rails app, you have a link to edit a user from two different views, one on the users index view, and another from another view (lets say from the nav bar on every page). I'm wondering what is the best w...

Rails Check box on MySql stored as a null or zero

On my rails app I have a list of items (like a task list) and for each item there is a couple of check box to set parameters. When I submit the form, the checked box are stored as zero and the unchecked as null on DB. the question is: Is there a way to configure it? To store the data on a more traditional 0 or 1, because I think that ...

How to change "3 errors prohibited this foobar from being saved" validation message in Rails?

In my rails app I use the validation helpers in my active record objects and they are great. When there is a problem I see the standard "3 errors prohibited this foobar from being saved" on my web page along with the individual problems. Is there any way I can override this default message with my own? ...

Grouping Activerecord query by a child attribute

Is it possible to use an attribute of a child to group a query? Post.find(:all, :include => [ :authors, :comments ], :group=>'authors.city') does not work. However, I am able to use author.city as part of the conditions. ...

Why do I get an error when starting ruby on rails app with mongrel_rails

Why do I get following error when trying to start a ruby on rails application with mongrel_rails start? C:\RailsTest\cookbook2>mongrel_rails start ** WARNING: Win32 does not support daemon mode. ** Daemonized, any open files are closed. Look at log/mongrel.pid and log/mongr el.log for info. ** Starting Mongrel listening at 0.0.0.0:30...

Monitoring a server-side process on Rails application using AJAX XMLHttpRequest

I'm using the following in the web page but can't get a response from the server while it's processing <script type="text/javascript"> <!-- function updateProgress() { //alert('Hello'); new Ajax.Request('/fmfiles/progress_monitor', { parameters: 'authenticity_token=' + encodeURIComponent(AUTH_TOKEN), onS...

Need advice: Structure of Rails views for submenus?

Imagine to have two RESTful controllers (UsersController, OffersController) and a PagesController (used for static content such as index, about and so on) in your application. You have the following routes defined: map.with_options :controller => 'pages' do |pages| pages.root :action => 'index' # static home page pages.about :a...

What is the best way in Rails to determine if two (or more) given URLs (as strings or hash options) are equal?

I'm wanting a method called same_url? that will return true if the passed in URLs are equal. The passed in URLs might be either params options hash or strings. same_url?({:controller => :foo, :action => :bar}, "http://www.example.com/foo/bar") # => true The Rails Framework helper current_page? seems like a good starting point but I'd ...

Ruby on Rails - Why use tests?

I'm confused about what the various testing appliances in Ruby on Rails are for. I have been using the framework for about 6 months but I've never understood the testing part of it. The only testing I've used is JUnit3 in Java and that only briefly. Everything I've read about it just shows testing validations. Shouldn't the validations ...