Info

バージョンアップされていろいろ変わりました。今回はプロジェクトの生成と簡単にScaffoldを使ってみました。

macbook:rails king$ rails demo
create
create app/controllers
create app/helpers
create app/models
create app/views/layouts
create config/environments
create config/initializers
create db
create doc
…..
create public/javascripts/application.js
create doc/README_FOR_APP
create log/server.log
create log/production.log
create log/development.log
create log/test.log
macbook:rails king$ cd demo
macbook:demo king$ vi config/database.yml
# SQLite version 3.x
# gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
# adapter: sqlite3
# database: db/development.sqlite3
# timeout: 5000
adapter: mysql
database: demo
host: localhost
username: king
password: {password}

macbook:demo king$ script/generate scaffold user email:string name:string age:integer
exists app/models/
exists app/controllers/
exists app/helpers/
create app/views/users
exists app/views/layouts/
exists test/functional/
exists test/unit/
create app/views/users/index.html.erb
create app/views/users/show.html.erb
create app/views/users/new.html.erb
create app/views/users/edit.html.erb
create app/views/layouts/users.html.erb
create public/stylesheets/scaffold.css
dependency model
exists app/models/
exists test/unit/
exists test/fixtures/
create app/models/user.rb
create test/unit/user_test.rb
create test/fixtures/users.yml
create db/migrate
create db/migrate/001_create_users.rb
create app/controllers/users_controller.rb
create test/functional/users_controller_test.rb
create app/helpers/users_helper.rb
route map.resources :users
macbook:demo king$ rake db:migrate
(
in /Users/king/develop/localhost/rails/demo)
== 1 CreateUsers: migrating ===================================================
— create_table(:users)
-> 0.0032s
== 1 CreateUsers: migrated (0.0033s) ==========================================

macbook:demo king$ script/server

ブラウザで確認してみる。http://0.0.0.0:3000/users/new

rails-scaffild.png

Comments

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Basic HTML is allowed. Your email address will not be published.

Subscribe to this comment feed via RSS