How can I use ActiveRecord on a database that has a column named ‘valid’? (DangerousAttributeError)

Try this: class MyTable < AR:Base class << self def instance_method_already_implemented?(method_name) return true if method_name == ‘valid’ super end end end It’s a hack, and it might not work in rails 3, but it could fix the problem for now. I found it on the ruby on rails mailing list If you wanted, you could … Read more

Which join syntax is better?

Well, “better” is subjective. There is some style here. But I’ll address your questions directly. Both perform the same Both are ANSI-compliant. The problem with the first example is that it is very easy to inadvertently derive the cross product (since it is easier to leave out join criteria) it also becomes difficult to debug … Read more

Show a one to many relationship as 2 columns – 1 unique row (ID & comma separated list)

I believe that the answer you need is a user-defined aggregate, similar to this one: CREATE FUNCTION gc_init(dummy VARCHAR(255)) RETURNING LVARCHAR; RETURN ”; END FUNCTION; CREATE FUNCTION gc_iter(result LVARCHAR, value VARCHAR(255)) RETURNING LVARCHAR; IF result=”” THEN RETURN TRIM(value); ELSE RETURN result || ‘,’ || TRIM(value); END IF; END FUNCTION; CREATE FUNCTION gc_comb(partial1 LVARCHAR, partial2 LVARCHAR) … Read more

Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints

This problem is usually caused by one of the following null values being returned for columns not set to AllowDBNull duplicate rows being returned with the same primary key. a mismatch in column definition (e.g. size of char fields) between the database and the dataset Try running your query natively and look at the results, … Read more