Displaying 2 results from an estimated 2 matches for "create_forum".
2007 Sep 23
4
Story Runner, autoincrementing
I''ve written a story and I run into a snag.
I''ve written the create_forum method and told it to set the id to 1
but when it creates the forum the id is autoincremented.
My forums table is empty but the id keeps incrementing the newest record on
creation.
When I run the story it comes out as something like 59 which fails my story
because I''m asking it to look at...
2007 Feb 24
0
after_create not creating the right object
...rum, 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...