[Rails] Single table inheritance - HowTo?
Iván Vega Rivera
ivanvega at gmail.com
Fri Jan 6 21:59:18 GMT 2006
Hi,
As per another member's suggestion, I'm trying to user STI. So I have
this table:
CREATE TABLE `settings` (
`id` int(11) unsigned NOT NULL auto_increment,
`type` char(40) NOT NULL default 'General',
`name` char(40) NOT NULL default '',
`value` char(128) NOT NULL default '',
`updated_on` datetime default NULL,
`comments` char(255) default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
And a row with a type = 'General', and name = 'front-page'
Then I have a setting.rb model, and also general_setting.rb and
user_setting.rb, where I only have:
class <TYPE>Setting < Setting
end
So, if I do General.find_by_name('front-page'), I expected to get the
value of the corresponding row, instead I get a nil object.
What could I possibly be doing wrong?
Thanks!
Ivan V.
More information about the Rails
mailing list