There has to be something obvious I'm overlooking in regards to associations and accessors. I think I just need a good shove in the right direction. TIA!
schema: CREATE TABLE `ticket_statuses` ( `id` int(11) NOT NULL, `status` varchar(255) default NULL, PRIMARY KEY (`id`) );
CREATE TABLE `tickets` ( `id` int(11) NOT NULL, `title` varchar(255) default NULL, `details` text, `status_id` int(11) default NULL, `opened_at` datetime default NULL, `closed_at` datetime default NULL, `last_activity_at` datetime default NULL, PRIMARY KEY (`id`), KEY `fk_ticket_status` (`status_id`), CONSTRAINT `fk_ticket_status` FOREIGN KEY (`status_id`) REFERENCES `ticket_statuses` (`id`) );
models: Ticket belongs_to :ticket_status TicketStatus has_many :tickets
Ticket belongs_to :ticket_status, :foreign_key => "status_id" TicketStatus has_many :tickets, :foreign_key => "status_id"
The problem you are facing is because rails can't infer the foreign key properly from the model name TicketStatus (it's looking for ticket_status_id).
Best,
-r