Rails scaffolding issue

Greetings friends,

im experiencing an issue with scaffolding, which im 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

On Sep 7, 10:41 am, JuKuen [email protected] wrote:

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.

That’s how scaffolding is (i think the change happened back in rails
2). If you want the old dynamic scaffolding stuff you could look at
something like active scaffold, or the old code was extracted into a
plugin (don’t know if it’s still maintained):

Fred

edit:
db/model names are plural/singular

If i understand it right, in new scaffold need to be specified each
column from the existing db?

In my case:
ruby script/generate scaffold Post title:string body:text
author:string status:string created_at:datetime updated_at:datetime

And it will migrate the outside rails made db and will be working as
is needed to be?
Tested it and its working this way. Asking because dont want to learn
it in wrong way.
Used some outdated information… :frowning:

Thanks

whan you scafolded you didnt spefified the field of the database , the
scafold creates empty views in that case , i think you didnt pass the
fields
because the scaffold fills the migration with them if you do, since i
see
the migration is empty that mians you did this

script/generate scaffold post
and it should have been

script/generate scaffold post title:string body:text and so on