I have 2 tables... club and forum, which use the "type" as
I''m
subclassing the Club and Forum objects. Tables are:
clubs:
id
title
type
forums:
id
club_id
title
type
I''ve put an "after_create" callback in the Club as Club
has_one Forum:
class Club < ActiveRecord::Base
after_create :create_forum
has_one :forum
def self.create_forum
# create it (taken from console)
@f = Forum.new(:title => ''Forum'', :club_id =>
self.id)
@f.save
@f.type = ''Forum''
@f.save
end
end
Now I know this is a bit "longhand", but if I do it from the console
as it is there, I end up with the right data in the table e.g. title,
club_id and type are correct. But if I create it via Club.create, it
doesn''t put in the type at all, thus making the application fail.
Success should put a record in the clubs table and a record in the
forums table with the correct type (Club and Forum). What I end up
with is a Club in the clubs table and a default type in the Forum
table.
Very confused. This should be working, and isn''t!
Any help would be very much appreciated.
Paul
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---