scaffold under rails2.0
来源:百度文库 编辑:神马文学网 时间:2024/04/27 22:06:09
摘录自http://fairleads.blogspot.com/2007/12/rails-20-and-scaffolding-step-by-step.html
In Rails 2.0 it willtake fewer steps, but may be a little harder to follow because so muchis accomplished with so few commands. First we need to think about themovie inventory table.
Startsimple. Movies should have, at minimum a title, a description and amovie poster. Columns for other data like release date, rating orquantity on hand can be added later by altering the table through migrations. The next step is to create a model whose job will be to manage the data stored in the database.
The following command will generate the model, plus scaffolding, and the database migration script needed as well as a controller, helper, and testing support files:
exchange$ ruby script/generate scaffold Movie title:string description:text one_sheet_url:string
exists app/models/
exists app/controllers/
exists app/helpers/
create app/views/movies
exists app/views/layouts/
exists test/functional/
exists test/unit/
create app/views/movies/index.html.erb
create app/views/movies/show.html.erb
create app/views/movies/new.html.erb
create app/views/movies/edit.html.erb
create app/views/layouts/movies.html.erb
create public/stylesheets/scaffold.css dependency model
exists app/models/
exists test/unit/
exists test/fixtures/
create app/models/movie.rb
create test/unit/movie_test.rb
create test/fixtures/movies.yml
create db/migrate
create db/migrate/001_create_movies.rb
create app/controllers/movies_controller.rb
create test/functional/movies_controller_test.rb
create app/helpers/movies_helper.rb
route map.resources :movies
Making Movies
The table will get created by the file in db/migrate/001_create_movies.rb .
In Rails 2.0 it willtake fewer steps, but may be a little harder to follow because so muchis accomplished with so few commands. First we need to think about themovie inventory table.
Startsimple. Movies should have, at minimum a title, a description and amovie poster. Columns for other data like release date, rating orquantity on hand can be added later by altering the table through migrations. The next step is to create a model whose job will be to manage the data stored in the database.
The following command will generate the model, plus scaffolding, and the database migration script needed as well as a controller, helper, and testing support files:
exchange$ ruby script/generate scaffold Movie title:string description:text one_sheet_url:string
exists app/models/
exists app/controllers/
exists app/helpers/
create app/views/movies
exists app/views/layouts/
exists test/functional/
exists test/unit/
create app/views/movies/index.html.erb
create app/views/movies/show.html.erb
create app/views/movies/new.html.erb
create app/views/movies/edit.html.erb
create app/views/layouts/movies.html.erb
create public/stylesheets/scaffold.css dependency model
exists app/models/
exists test/unit/
exists test/fixtures/
create app/models/movie.rb
create test/unit/movie_test.rb
create test/fixtures/movies.yml
create db/migrate
create db/migrate/001_create_movies.rb
create app/controllers/movies_controller.rb
create test/functional/movies_controller_test.rb
create app/helpers/movies_helper.rb
route map.resources :movies
Making Movies
The table will get created by the file in db/migrate/001_create_movies.rb .
scaffold under rails2.0
Web2.0 Application under Education
Install Trac under Ubuntu
SOVEREIGNTY UNDER SIEGE
under the moonlight
Install Trac under Ubuntu
Shanghai official under investigation
rails2.02快速体验 - rails - Ruby - JavaEye论坛
Shanghai official under investigation k
I/O Event Handling Under Linux
CUBA - will changes happen under Raul Castro?
60% Chinese paid under RMB3,000
St. Sebastian muck dredging under way - Ellic...
FOXNews.com - Offshore Drilling Plans Under G...
Getting Things Done: Getting Projects Under Control
Under the Hawthorn Tree 《山楂树之恋》
2000年悉尼奥运会歌曲:Under Southern Skie
Weak NAND Flash demand, SSD market is under expectation. The 2009 market is still under oversupply
windows下的rails2.02环境搭建指南 - rails - Ruby - Jav...
Enterprise Java Community: Under the Hood of J2EE Clustering
Under A Violet Moon 胡言乱语: 在紫罗兰月光下
Wine Spectator Online | Daily Wine Picks Under $15
Cuba under Raúl: Creeping toward capitalism?
Under A Violet Moon 胡言乱语: 在紫罗兰月光下