rails勉強日記

すっごいいまさらですが、railsの勉強をする必要ができたので、日記をつけることにします。
教科書はこちら。
[rakuten:book:11875045:detail]
実況中継形式だったので、実際にやってみるのが早いか、と思いました。
p1インストール
FreeBSDの環境はあるのですが、まあ手元にあった方が何かと便利だと思いますので、Windowsに入れます。
[[RubyInstaller:http://rubyinstaller.rubyforge.org/wiki/wiki.pl]]からruby186-25.exeをインストール。
RubyGemsを入れようと思ったのだけれど、RubyInstallerでインストールされたみたいだったので、そのまま行きます。

>
C:\WINDOWS\system32>sqlite3.exe
SQLite version 3.4.0
Enter “.help” for instructions
sqlite> exit
…> ;
SQL error: near “exit”: syntax error
sqlite> .exit
C:\WINDOWS\system32>sqlite3.exe -v
sqlite3.exe: unknown option: -v
Use -help for a list of options.
C:\WINDOWS\system32>sqlite3.exe –version
3.4.0
C:\WINDOWS\system32>gem install sqlite3-ruby
Select which gem to install for your platform (i386-mswin32)
1. sqlite3-ruby 1.2.1 (mswin32)
2. sqlite3-ruby 1.2.1 (ruby)
3. sqlite3-ruby 1.2.0 (mswin32)
4. sqlite3-ruby 1.2.0 (ruby)
5. Skip this gem
6. Cancel installation
1
Successfully installed sqlite3-ruby-1.2.1-mswin32
Installing ri documentation for sqlite3-ruby-1.2.1-mswin32…
Installing RDoc documentation for sqlite3-ruby-1.2.1-mswin32…
E:\tmp>gem install rails –include-dependencies –version 1.1.2
Need to update 21 gems from http://gems.rubyforge.org
…………………
complete
Successfully installed rails-1.1.2
Successfully installed activesupport-1.3.1
Successfully installed activerecord-1.14.2
Successfully installed actionpack-1.12.1
Successfully installed actionmailer-1.2.1
Successfully installed actionwebservice-1.1.2
Installing ri documentation for activesupport-1.3.1…
While generating documentation for activesupport-1.3.1
… MESSAGE: Unhandled special: Special: type=17, text=”
… RDOC args: –ri –op D:/ruby/lib/ruby/gems/1.8/doc/activesupport-1.3.1/ri –quiet lib
(continuing with the rest of the installation)
Installing ri documentation for activerecord-1.14.2…
Installing ri documentation for actionpack-1.12.1…
While generating documentation for actionpack-1.12.1
… MESSAGE: Unhandled special: Special: type=17, text=”
… RDOC args: –ri –op D:/ruby/lib/ruby/gems/1.8/doc/actionpack-1.12.1/ri –quiet lib
(continuing with the rest of the installation)
Installing ri documentation for actionmailer-1.2.1…
Installing ri documentation for actionwebservice-1.1.2…
Installing RDoc documentation for activesupport-1.3.1…
Installing RDoc documentation for activerecord-1.14.2…
Installing RDoc documentation for actionpack-1.12.1…
Installing RDoc documentation for actionmailer-1.2.1…
Installing RDoc documentation for actionwebservice-1.1.2…
<>
C:\WINDOWS\system32>cd E:\tmp
C:\WINDOWS\system32>e:
E:\tmp>mkdir schduler
E:\tmp>cd schduler
E:\tmp\schduler>cd ../
E:\tmp>rmdir schduler
E:\tmp>rails scheduler –database=sqlite3
create
create app/controllers
create app/helpers
create app/models
create app/views/layouts
create config/environments
create components
create db
create doc
create lib
create lib/tasks
create log
create public/images
create public/javascripts
create public/stylesheets
create script/performance
create script/process
create test/fixtures
create test/functional
create test/integration
create test/mocks/development
create test/mocks/test
create test/unit
create vendor
create vendor/plugins
create tmp/sessions
create tmp/sockets
create tmp/cache
create tmp/pids
create Rakefile
create README
create app/controllers/application.rb
create app/helpers/application_helper.rb
create test/test_helper.rb
create config/database.yml
create config/routes.rb
create public/.htaccess
create config/boot.rb
create config/environment.rb
create config/environments/production.rb
create config/environments/development.rb
create config/environments/test.rb
create script/about
create script/breakpointer
create script/console
create script/destroy
create script/generate
create script/performance/benchmarker
create script/performance/profiler
create script/process/reaper
create script/process/spawner
create script/process/inspector
create script/runner
create script/server
create script/plugin
create public/dispatch.rb
create public/dispatch.cgi
create public/dispatch.fcgi
create public/404.html
create public/500.html
create public/index.html
create public/favicon.ico
create public/robots.txt
create public/images/rails.png
create public/javascripts/prototype.js
create public/javascripts/effects.js
create public/javascripts/dragdrop.js
create public/javascripts/controls.js
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
E:\tmp>cd scheduler
<>
E:\tmp\scheduler>dir
ドライブ E のボリューム ラベルは ローカル ディスク です
ボリューム シリアル番号は D048-737D です
E:\tmp\scheduler のディレクトリ
2007/07/20 08:44 .
2007/07/20 08:44 ..
2007/07/20 08:44 app
2007/07/20 08:44 components
2007/07/20 08:44 config
2007/07/20 08:44 db
2007/07/20 08:44 doc
2007/07/20 08:44 lib
2007/07/20 08:44 log
2007/07/20 08:44 public
2007/07/20 08:44 307 Rakefile
2007/07/20 08:44 8,001 README
2007/07/20 08:44 script
2007/07/20 08:44 test
2007/07/20 08:44 tmp
2007/07/20 08:44 vendor
2 個のファイル 8,308 バイト
14 個のディレクトリ 24,802,045,952 バイトの空き領域
E:\tmp\scheduler>take -T
‘take’ は、内部コマンドまたは外部コマンド、
操作可能なプログラムまたはバッチ ファイルとして認識されていません。
E:\tmp\scheduler>rake -T
(in E:/tmp/scheduler)
rake db:fixtures:load # Load fixtures into the current environment’s d
tabase. Load specific fixtures using FIXTURES=x,y
rake db:migrate # Migrate the database through scripts in db/mig
ate. Target specific version with VERSION=x
rake db:schema:dump # Create a db/schema.rb file that can be portabl
used against any DB supported by AR
rake db:schema:load # Load a schema.rb file into the database
rake db:sessions:clear # Clear the sessions table
rake db:sessions:create # Creates a sessions table for use with CGI::Ses
ion::ActiveRecordStore
rake db:structure:dump # Dump the database structure to a SQL file
rake db:test:clone # Recreate the test database from the current en
ironment’s database schema
rake db:test:clone_structure # Recreate the test databases from the developme
t structure
rake db:test:prepare # Prepare the test database and load the schema
rake db:test:purge # Empty the test database
rake doc:app # Build the app HTML Files
rake doc:clobber_app # Remove rdoc products
rake doc:clobber_plugins # Remove plugin documentation
rake doc:clobber_rails # Remove rdoc products
rake doc:plugins # Generate documation for all installed plugins
rake doc:rails # Build the rails HTML Files
rake doc:reapp # Force a rebuild of the RDOC files
rake doc:rerails # Force a rebuild of the RDOC files
rake log:clear # Truncates all *.log files in log/ to zero byte
rake rails:freeze:edge # Lock to latest Edge Rails or a specific revisi
n with REVISION=X (ex: REVISION=4021) or a tag with TAG=Y (ex: TAG=rel_1-1-0)
rake rails:freeze:gems # Lock this application to the current gems (by
npacking them into vendor/rails)
rake rails:unfreeze # Unlock this application from freeze of gems or
edge and return to a fluid use of system gems
rake rails:update # Update both configs, scripts and public/javasc
ipts from Rails
rake rails:update:configs # Update config/boot.rb from your current rails
nstall
rake rails:update:javascripts # Update your javascripts from your current rail
install
rake rails:update:scripts # Add new scripts to the application script/ dir
ctory
rake stats # Report code statistics (KLOCs, etc) from the a
plication
rake test # Test all units and functionals
rake test:functionals # Run the functional tests in test/functional
rake test:integration # Run the integration tests in test/integration
rake test:plugins # Run the plugin tests in vendor/plugins/**/test
(or specify with PLUGIN=name)
rake test:recent # Test recent changes
rake test:uncommitted # Test changes since last checkin (only Subversi
n)
rake test:units # Run the unit tests in test/unit
rake tmp:cache:clear # Clears all files and directories in tmp/cache
rake tmp:clear # Clear session, cache, and socket files from tm
/
rake tmp:create # Creates tmp directories for sessions, cache, a
d sockets
rake tmp:pids:clear # Clears all files in tmp/pids
rake tmp:sessions:clear # Clears all files in tmp/sessions
rake tmp:sockets:clear # Clears all files in tmp/sockets
E:\tmp\scheduler>ruby script\generate migration create_schedules
create db/migrate
create db/migrate/001_create_schedules.rb
<>
class CreateSchedules < ActiveRecord::Migration
def self.up
create_table(:schedules) do |table|
table.column(:datatime, :timestamp)
table.column(:title, :string)
table.column(:content, :text)
end
end
def self.down
drop_table(:schedules)
end
end
<>
E:\tmp\scheduler>rake db:migrate –trace
(in E:/tmp/scheduler)
E:0:Warning: require_gem is obsolete. Use gem instead.
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
== CreateSchedules: migrating =================================================
— create_table(:schedules)
-> 0.0600s
== CreateSchedules: migrated (0.0600s) ========================================
** Invoke db:schema:dump (first_time)
** Invoke environment
** Execute db:schema:dump
<<
でもDBはできてしまう。SQLite_Database_Browserで覗いたら、ちゃんとできていました。
一日目、終わり。