Hi, has anyone successfully used the acts_as_threaded plugin with
postgresql?
I’m using rails 1.0 and ruby 1.8.4 on linux.
Following the screencast on
http://www.railtie.net/articles/2006/02/05/rails-acts_as_threaded-plugin
,
I got to where we’re ready to create our first post, having made the
changes to controllers/posts_controller.rb, views/posts/_form.rhtml,
views/posts/show.rhtml, and models/post.rb as shown in the screencast.
When I submit the post I get an SQL error:
PGError: ERROR: null value in column “root_id” violates not-null
constraint:
INSERT INTO posts (“name”, “updated_at”, “body”, “depth”, “lft”,
“subject”, “root_id”, “parent_id”, “rgt”, “created_at”)
VALUES(‘Richard Nixon’, ‘2006-03-14 19:45:58’,
‘Erase tape number 2347!’, 0, 0, ‘Memo’, NULL, NULL, 0,
‘2006-03-14 19:43:00’)
We can see NULL values being provided for root_id and parent_id,
and I believe this to be incorrect. (I tried removing the NOT NULL
constraints, but got NoMethodError for nil exceptions further along.)
Note: The depth, lft, and rgt fields would have been NULL also, but I
set them to zero in the form manually before submitting the form.
This seems to be a key difference from the screencast. The
screencast shows the form already displaying default values of
zero for Depth, Lft, and Rgt:
http://tastyspleen.net/~billk/acts_as_threaded_post_defaults.png
Whereas in my app, these fields are blank:
http://tastyspleen.net/~billk/acts_as_threaded_post_nodefaults.png
Can anyone suggest any hints or ideas as to why the form in
the screencast would have default values pre-populated for some fields,
but my application presents the form with these fields uninitialized?
These are the files I’ve modified from the scaffold, with only the
very slight changes shown in the screencast:
http://cila-search.net/~billk/forum_060314/app/models/post.rb
http://cila-search.net/~billk/forum_060314/app/controllers/posts_controller.rb
http://cila-search.net/~billk/forum_060314/app/views/posts/_form.rhtml
http://cila-search.net/~billk/forum_060314/app/views/posts/show.rhtml
Thanks for any help, hints, suggestions, possibilities, etc. !
Regards,
Bill