ruby-on-rails

Selenium RC: Run tests in multiple browsers automatically

So, I've started to create some Ruby unit tests that use Selenium RC to test my web app directly in the browser. I'm using the Selenum-Client for ruby. I've created a base class for all my other selenium tests to inherit from. This creates numerous SeleniumDriver instances and all the methods that are missing are called on each instan...

Which is better for a rails site? /{login} or /user/{login}

Which is better (for the user, for longevity, for performance, for whatever) to have: http://{site}/{login} e.g. http://wildobs.com/adam_jack or http://{site}/user/{login} Pros of former: User feels more special. URLs are shorter. Cons of former: Cannot have users w/ logins matching keywords, and keywords likely grow over time....

Parsing Atom & RSS in Ruby/Rails?

I'm looking for something that will let me parse Atom and RSS in Ruby and Rails. I've looked at the standard RSS library, but is there one library that will auto-detect whatever type of feed it is and parse it for me? ...

Sanitize output in rails

What is the best solution to sanitize output html in rails (to avoid XSS attacks)? I have two options: white_list plugin or sanitize method from Sanitize Helper http://api.rubyonrails.com/classes/ActionView/Helpers/SanitizeHelper.html? For me until today the white_list plugin worked better and in the past, Santize was very buggy, but as...

One Rails application, several domain names

I want to point several domain names to the same Rails application. The content is different for each domain, but the functionality and the structure of the application is the same. What is the best way to do this when it comes to server set up and routing? I will use nginx as a web server. ...

Rails: Sorting a query by params?

I am using running a simple find all and paginating with willpaginate, but I'd also like to have the query sorted by the user. The first solution that came to mind was just use a params[:sort] http://localhost:3000/posts/?sort=created_at+DESC @posts = Post.paginate :page => params[:page], :order => params[:sort] But the problem with ...

Can you create an ASP.NET editing system for a class just by defining it?

I was watching a tutorial on Rails and was very impressed that you could so easily create an editing system for a class just by defining it. Can this be done in ASP.NET? I know there are ORMs out there, but do they come with an editing system? To explain what I mean by an editing system, consider a class for defining people class Per...

Using the after_save callback to modify the same object without triggering the callback again (recursion)

Hi, If I add an after_save callback to an ActiveRecord model, and on that callback I use update_attribute to change the object, the callback is called again, and so a 'stack overflow' occurs (hehe, couldn't resist). Is it possible to avoid this behavior, maybe disabling the callback during it's execution? Or is there another approach? ...

How do I only show items that belong to a certain user (using restful_authentication)?

I have a web application with users and their documents. Each user can have many documents: user.rb: has_many :documents document.rb: belongs_to :user document_controller.rb: def index @documents = Document.find(:all) end I am using the restful_authentication plugin. Here is my question: How do I get the controller to only...

Managing database changes between a Rails and Java project

At a new job I started, we have both a Java application that handles most of the heavy lifting in the core business logic, and we also have a Rails application that of course handles the web interface to this server. Both of these access the same database. Up until now, most of the focus has been on the Java application, and as such, t...

Design decision: Dynamically adding data question.

I need to give users the ability to optionally add metadata to documents. Another way to state this is the fact that users need to add at least 5 categories to a document. Basically what I want to do is dynamically add metadata (or categories) to a document on an ad hoc basis. Here are the options that I have thought of: Option 1: Shou...

Rake db:migration problem

Hi, i've got a unfinished project that a developer just didn't finish and didn't let any documentation about the installation process. I've downloaded the production directory to my windows machine (running InstantRails 2), i created the databases as required in the database.yml and i tried to run the rake:db:migrate --trace but i'm rece...

Given an array of ActiveRecord objects, can I easily collect their relationships through a method call?

Let's say I have the following code: @sites = Site.find(session[:sites]) # will be an array of Site ids @languages = Language.for_sites(@sites) for_sites is a named_scope in the Language model that returns the languages associated with those sites, and languages are associated with sites using has_many through. The goal is for @langua...

Single Table Inheritance find issues

I have the following 3 rails classes, which are all stored in one table, using rails' Single table inheritance. class Template < ActiveRecord::Base class ThingTemplate < Template class StockThingTemplate < ThingTemplate If I have a StockThingTemplate with ID of 150 then I should logically be able to do this: ThingTemplate.find(150) =...

Continuous Integration for Ruby on Rails?

I've been searching around for a Continuous Integration solution for Ruby on Rails, but haven't been too pleased with the results. I came from a .NET shop that used CruiseControl.NET and was really spoiled with it's ease of use and rich status/reporting. Ideally I'm looking for: The obvious Git/SVN and Test::Unit integration Integrat...

Ruby on Rails and jeditable (jquery)

Hi there, Has anyone gotten the jquery plugin jeditable to run properly in a Rails applications. If so, could you share some hints on how to set it up? I'm having some trouble with creating the "submit-url". Regards, Sebastian ...

Cannot start workling_starling_client in rails production environment

I was using god to start and monitor my starling and workling daemons. Works awesome on development machine but "workling_starling_client" refuses to start on my production machine. ...

How to display events in the calendar using Ruby?

I am building a calendaring application in ruby on rails. I am using my own schema for storing events, but I don't know how to display events in calendar, and also how to add a calendar in my application. Will I have to write code to display calendar or can I use any plugin to display calendar. ...

Excluding some ActiveRecord properties from xml rendering in rails

I have an ActiveRecord model that I would like to convert to xml, but I do not want all the properties rendered in xml. Is there a parameter I can pass into the render method to keep a property from being rendered in xml? Below is an example of what I am talking about. def show @person = Person.find(params[:id]) respond_to do |for...

Composite keys with ActiveScaffold in Ruby On Rails

I am developing RoR application that works with legacy database and uses ActiveScaffold plugin for fancy CRUD interface. However one of the tables of my legacy db has composite primary key. I tried using Composite Keys plugin to handle it, but it seems to have conflicts with ACtiveScaffold: I get the following error: ActionView::Templa...