ruby-on-rails

Correctly doing redirect_to :back in Ruby on Rails when referrer is not available

Hi there, I'm having a problem with redirect_to :back. Yes, it's referrers. I often get the exception (ActionController::RedirectBackError) "No HTTP_REFERER was set in the request to this action, so redirect_to :back could not be called successfully. If this is a test, make sure to specify request.env[\"HTTP_REFERER\"]." I realise tha...

accessing children of children tables in Rails

I have a "tree-like" structure to my database in an app I am writing so that: training has_many class_times and class_time has_many reservations Is there a way to look up all reservations under a a given training? I could iterate through all of class times/add a foreign key, of course, but for some reason I have this little voice...

Remove ":" from the ruby on rails time_select helper output?

I want to remove the ":" from the output of the rails time_select helper. The helper seems to output this automatically when the minutes select box is built. Any ideas? Thanks! ...

"Tab order" in a rails app

In a rails app, I want users to be able to enter data without having to use a mouse. To help do this, I want to set the order in which the cursor moves to text fields, drop-down boxes, and buttons. Is there a way to do this? ...

Rails web application control panel with ajax tabs and validation

I'm looking to build a rails web app with an admin control panel. I'd like the control panel to use a tabbed interface for controlling users, projects, tasks etc, and I'd like to switch between tabs using jquery tab UI controls with ajax. Also using restful authentication for users and my own code for projects, tasks etc. Here's what ...

FileTest.exists? issue with ruby on rails

Hi, I am trying to check if a file exists in my rails application. I am running ruby 1.8.6 and rails 2.1.2 with windows XP. So, the problem is that the FileTest.exists? method doesn't seem to be working. I have simplified the code to this point : if FileTest.exists?("/images/header.jpg") render :text => "yes" else render...

Ruby: Reading PDF files

I'm looking for a fast and reliable way to read/parse large PDF files in Ruby (on Linux and OSX). Until now I've found the rather old and simple PDF-toolkit (a pdftotext-wrapper) and PDF-reader, which was unable to read most of my files. Though the two libraries provide exactly the functionality I was looking for. My question: Have I ...

Is it okay for my online store to send order confirmation emails via Gmail synchronously?

When a user completes an order at my online store, he gets an email confirmation. Currently we're sending this email via Gmail (which we chose over sendmail for greater portability) after we authorize the user's credit card and before we show him a confirmation message (i.e., synchronously). It's working fine in development, but I'm wo...

Ruby IDEs: any worth looking at?

I currently use TextMate for all my Rails development, and I like it very much, but I wonder if I'm missing anything by not using an IDE. Has anyone switched from using TextMate or another powerful text editor to a Ruby IDE? Am I missing anything? ...

Rails Search Plugins & Solutions

I'm looking to add a search box on my Rails site and was wondering if you could recommend me solutions for conducting general searches across designated columns. I've noticed the acts_as_ferret plugin which seems good, but I'm also looking for other opinions. Any leads or suggestions would be greatly appreciated. Thanks for looking! ...

How should I upgrade a Rails app to use the latest version of Rails

I'm working on a Rails app that currently uses Rails 1.2, so I'm now quite a long way behind the latest stable release (Rails 2.3). How should I go about the process of moving to a newer version of Rails? Should I upgrade one point release at a time or straight to Rails 2.3? How do I find out what has changed between versions of R...

Basic Rails Question: One-to-One relationships

My comprehension of RoR is sadly lacking. I have three one-to-one relationships that I want to maintain in one view. I have the following models: class Ood< ActiveRecord::Base has_one :female_trait has_one :male_trait end class Female_Trait < ActiveRecord::Base belongs_to :ood end class Male_Trait < ActiveRecord::Base belon...

Rails: Mimic relations in tableless activerecord

Hi Everyone, I'm using the BaseWithoutTable plugin to extend ActiveRecord. This allows me to create models without underlying tables (I'm getting data from a webservice). I would like my web application to remain restful, however i'm stumped on how to do that without relations. To be more concrete, let's say I have a book model and...

What Ruby programming book should I read first?

I'm am an experienced developer in other languages like C#, VB.net and C++, but a real newbie in Ruby. What Ruby book do you think should I read first? ...

how do I set as an option d=identicon when using the gravatar plugin?

I have set up the gravatar RoR plugin successfully (yeah!) but when someone does NOT have a gravatar account, I want it to display the identicon, which I guess shows up when d=identicon in the gravatar URL...but since I am using the plugin, I am basically saying gravatar_for (user) so...is there a way to add that value? Thanks! ...

Rails for Django developers

Hi. I am used to using Django for some time now. Now I have to learn some RoR. Are there any good RoR tutorials that explain things in terms someone used to Django would understand, ie, is there a "polls" tutorial for RoR? ...

How to create activerecord style validations outside of activerecord?

Hi, I am working on a testing framework for the software that my company writes. Our product is web based and After I run a RESTful request I want to process the results. I want to be able to have activerecord type validations in each command class so that after it is run the results are automatically tested against all the "validation...

Dynamic CMS like routes in ruby on rails

I want to create a CMS like site where the user starts off with a some generic pages, i.e. homepage about contact etc and from there can add child pages dynamically, for example homepage articles article1 something something-else article2 about contact etc To achieve this I'm planning on using some kind of self-referentia...

Escaping HTML entities in the URL of a rails remote_function

Some content in my page is loaded dynamically with the use of this code : javascript_tag( remote_function( :update => agenda_dom_id, :url => agenda_items_url(options), :method => :get ) ) When it outputs in the browser, it comes out as this : new Ajax.Updater('agenda', 'http://localhost:3000/agenda_items?company=43841&amp;amp;history...

What's the best way to talk to a database while using Sinatra?

As I understand it, the Sinatra framework, unlike Rails, does not provide an ORM. In that case, how do you talk to a DB in a Sinatra app? Or is Sinatra only for apps that don't use a DB? ...