Greetings friends,
im experiencing an issue with scaffolding, which i
m unable to
resolve for the moment.
system used:
win7 x64: ruby -v 1.9.1, gem -v 1.3.7, rails -v 2.3.8. mysql 5.1.50,
but downgraded to 5.0.37
win xp x86: ruby -v 1.9.2, gem -v 1.3.7, rails - 3. mysql 5.1.50, but
downgraded to 5.0.37
slackware 13.1: ruby -v 1.9.2, gem -v 1.3.7, rails - 3. mysql 5.1.34
i have full mysql access, it is working, the issue persist in sqlite3
aswell
When i try to scaffold from the existing table, im not getting the
error while scaffolding, but after that the migration file is empty:
class CreatePosts < ActiveRecord::Migration
def self.up
create_table :posts do |t|
t.timestamps
end
end
def self.down
drop_table :posts
end
end
When i fill it by hand,
class CreatePosts < ActiveRecord::Migration
def self.up
create_table :posts do |t|
t.column :title, :string, :limit => 100, :null => false
t.column :body, :text, :nill => false
t.column :author, :string, :limit => 100, :null => false
t.column :status, :string, :limit => 20, :null => false
t.column :created_at, :datetime
t.column :updated_at, :datetime
end
end
def self.down
drop_table :posts
end
end
and i try to test my app in the browser, i dont get the scaffolded
fields, just one single button, when i click it, its renders the “new
form” and there is only the create button alone, but when i click it,
im getting the next error:
ActiveRecord::StatementInvalid in PostsController#create
SQLite3::ConstraintException: posts.title may not be NULL: INSERT INTO
“posts” (“title”, “body”, “author”, “status”, “created_at”,
“updated_at”) VALUES(NULL, NULL, NULL, NULL, ‘2010-09-07 08:53:20’,
‘2010-09-07 08:53:20’)
RAILS_ROOT: D:/sites/new
this is because sent information is empty, but there are no fields in
the application.
the problem is existing only if i use existing table in mysql, or
trying to create migrations by hand.
when i do:
ruby script/generate scaffold Post blahblah:sting
blahblah:text…, it is working fine
with sqlite3.
Any help will be helpful
Thanks in Advance