ruby-on-rails

Different Log File For Specific Controller

I currently have a controller were I would like to keep track of logging in a separate log file, like: tracker.log. I currently get about 100,000 hits a day with this, and I would like to separate the log from all the other controllers so I can easily debug those as well as the tracker. I couldn't find anything for the Rails::Initializer...

Rails Routing

Hi All, I have built a new portal on Rails which can be accessed as say: https://xyz.com The problem with this is: 1.) It has 2 tabs – “ShipmentInfo” , “Aging Shipments Dashboard” both implemented using <li> tags and YUI library’s tabview. <ul class="yui-nav"> <li id="tab1" class="selected"><a href="#tab1">Shipment ...

How to avoid short-circuit evaluation on

I'm working with Ruby on Rails and would like to validate two different models : if (model1.valid? && model2.valid?) ... end However, "&&" operator uses short-circuit evaluation (i.e. it evaluates "model2.valid?" only if "model1.valid?" is true), which prevents model2.valids to be executed if model1 is not valid. Is there an equivale...

What is the best way to maintain a record's edit history with Rails and ActiveRecord

What is the best/cleanest/easiest way to maintain the edit history of records in Rails? I'm looking for logging - who made the edits and when and the ability to rollback to earlier versions of records. My guess is that you would use ActiveRecord callbacks on updates or deletes and instead of updating/deleting records you would create a...

Automated code sanity check tools for Ruby

What tools do you use for automated code sanity checks and adhering to the coding conventions in your Ruby apps? How do you incorporate them into your process? (I mean tools like roodi, reek, heckle, rcov, dcov, etc.) ...

Tricky integration of a legacy PHP app and a new Ruby on Rails app

We have an old legacy PHP application. Now I want to write a new application module using Ruby on Rails. Deployment is a one problem. I guess that it should be possible to run PHP app (via mod_php) and RoR app (via mod_proxy / mongrel) on a one Apache server. I don't want to use mod_rails because it requires to run php via fcgi. So is ...

Misuse of English in the computer literature.....

So recently in the Rails literature the non-word (please, no down grades, I know non-word is a non-word but I'm not publishing this stuff and I don't claim to be more intelligent than those who write books :) P "dasherize" has become somewhat of a de-facto term as in: "to_xml will default to dasherizing the field names" Now in every ot...

Rails - make_resourceful with nested resources

I am using the make_resourceful plugin in my Rails app, and attempting to use nested resources. My controller code looks like this: class ClientRegionsController < ApplicationController make_resourceful do actions :all belongs_to :client response_for(:create) do |format| format.html { redirect_to client_client_regi...

Request Tracker on Rails?

I'm building an app which is going to have to handle and store a large amount of email (around 2-4 thousand a day) which will need to be seen and dealt with in various ways by a lot of people worldwide. Sounds like a ticketing system, right? With one twist -- I have a separate app which handles a lot of the processing for people who wi...

For one of my models, I have a few instances that should be auto-populated. How do I handle this?

I have to be specific for this to make sense. In my application I have a model called theme which contains widget color theme information. We provide a few themes, but mainly rely on the user to create their own themes. So the question is: where do I store my themes? If I store them in the theme database, then anytime I switch databas...

Asserts in Rails from models or controllers?

Is there a built-in way of specifying asserts in Rails that will throw an exception if an invariant is broken during development and testing? Edit: Just to be clear, I'm looking for asserts that can be placed in models or controllers as opposed to asserts that you would use for unit tests. ...

Using helpers in model: how do I include helper dependencies?

I'm writing a model that handles user input from a text area. Following the advice from http://blog.caboo.se/articles/2008/8/25/sanitize-your-users-html-input, I'm cleaning up the input in the model before saving to database, using the before_validate callback. The relevant parts of my model look like this: include ActionView::Helpers...

Can ActiveScaffold be configured to show the search form before displaying a list?

When I ask ActiveScaffold to show me a very long list (for example the list of products sold), it runs the database query to get the first page of data and it displays it. If the list has a few relations, this query might take some time to execute (over a second). Most of the time, I'm not interested in this "unfiltered" list: the firs...

Ruby array manipulation (Ruby 1.8 and Rails 2.2)

I'm hopelessly trying to write a method to manipulate an array in ruby. I'm trying to generate all in-order permutations of an array where each item is in turn replaced by an outside item. An example... Given input: arr = ["a", "b", "c"] Desired output: newArr = [ ["a", "b", "c"], ["a", "b", "*"], ["a", "*", "c"], ["a", "*", "*"],...

Build a table at runtime in Ruby on Rails

How would I go about creating multiple database tables at runtime that utilize the same model given that rails wants to infer the table name from the model name? I want to be able to create a new object based on a model, then create a new table with a unique name that the object will reference. Does anyone have any examples or advice t...

Best way to export a database table to a YAML file?

I have some data in my development database that I would like to utilize as fixtures in my test environment. What is the best way in Rails 2.x to export a database table to a YAML fixture? ...

Change controller.action_name in Rails

I am in one action on Rails, but I wish to continue processing from within another action. My code looks like this: send(new_action) #call the new_action method action_name = new_action #change the controller.action_name render :action => new_action #inform the view that we're in new_action this works, b...

Speed of running a test suite in Rails

I have 357 tests (534 assertions) for my app (using Shoulda). The whole test suite runs in around 80 seconds. Is this time OK? I'm just curious, since this is one of my first apps where I write tests extensively. No fancy stuff in my app. Btw.: I tried to use in memory sqlite3 database, but the results were surprisingly worse (around 83...

Where do I find documentation for Rails 1.2?

The documentation at http://rubyonrails.org/documentation appears to be for the latest version of Rails, but I'm working on a Rails 1.2 app. Where can I find relevant documentation? ...

Is there equivalent for PHP's print_r in Ruby / Rails ?

In PHP you can do: print_r($var) or vardump($var) which prints "human-readible" information about variable. Is there equivalent functions / helpers for those in Ruby / Rails ? ...