blewis
September 13, 2006, 1:06am
1
I have a model columns, and here’s the table data:
class CreateComments < ActiveRecord::Migration
def self.up
create_table :comments do |t|
t.column :title, :string, :limit => 100
t.column :comment, :text
t.column :meeting_id, :integer
t.column :user_id, :integer
t.column :posted_at, :datetime
t.column :comment_id, :integer
end
end
def self.down
drop_table :comments
end
end
Then, I did script/generate scaffold comment comment
It created all the files. However, when I try to “create new” it
throws an error:
http://rafb.net/paste/results/zaAxQb54.html
I’m totally bewildered. What could be causing this error? There are
no validations in the model.
Thanks,
Ben L.
blewis
September 13, 2006, 1:38am
2
Does this do the trick if you modify your class definition as follows:
class Comment < ActiveRecord::Base
set_table_name “comments”
blewis
September 13, 2006, 2:40am
4
On Tue, 2006-09-12 at 23:01 +0000, Ben L. wrote:
t.column :comment_id, :integer
It created all the files. However, when I try to “create new” it
throws an error:
http://rafb.net/paste/results/zaAxQb54.html
I’m totally bewildered. What could be causing this error? There are
no validations in the model.
You probably should have done it like…
script/generate scaffold Comment
you might want to
script/destroy model comment
script/destroy controller comment
and try again
Craig
blewis
September 13, 2006, 2:50am
5
Craig -
Thanks for letting me know about the script/destroy! I didn’t know
about that hehe. What you said didn’t work, but I think it all had to
do with my sql. I did rake db:migrate VERSION=0 then did rake
db:migrate, then regenerated the scaffold and it worked. Thanks for
the help, it’s much appreciated!
-Ben