Child pages
  • Using Ruby on Rails 3.0.5 on O.I.
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

  1. install ruby
  2. "gem update --system" to update to latest gem tool.
    1. If behind firewall, "gem update --http-proxy --system"
  3. Install sqlite3 so that we have a database backend for testing.
    1. "gem install sqlite3" to kickoff a build that need gcc compiler installed.
  4. A quick check of installed Ruby stuff.
    oi@oi:~$ ruby -v
    ruby 1.8.7 (2009-06-12 patchlevel 174) [i386-solaris2.11]
    oi@oi:~$ gem -v
    oi@oi:~$ gem env
    RubyGems Environment:
      - RUBYGEMS VERSION: 1.6.2
      - RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [i386-solaris2.11]
      - INSTALLATION DIRECTORY: /var/ruby/1.8/gem_home
      - RUBY EXECUTABLE: /usr/ruby/1.8/bin/ruby
      - EXECUTABLE DIRECTORY: /var/ruby/1.8/gem_home/bin
        - ruby
        - x86-solaris-2.11
      - GEM PATHS:
         - /var/ruby/1.8/gem_home
         - /export/home/oi/.gem/ruby/1.8
         - /usr/ruby/1.8/lib/ruby/gems/1.8
         - :update_sources => true
         - :verbose => true
         - :benchmark => false
         - :backtrace => false
         - :bulk_threshold => 1000
    oi@oi:~$ uname -a
    SunOS oi 5.11 oi_148 i86pc i386 i86pc
  5. Create a test rails app "demo1"
    tjyang@oi:~$ rails new demo1
          create  README
          create  Rakefile
          create  .gitignore
          create  Gemfile
          create  app
          create  app/controllers/application_controller.rb
          create  app/helpers/application_helper.rb
          create  app/mailers
          create  app/models
          create  app/views/layouts/application.html.erb
          create  config
          create  config/routes.rb
          create  config/application.rb
          create  config/environment.rb
          create  config/environments
          create  config/environments/development.rb
          create  config/environments/production.rb
          create  config/environments/test.rb
          create  config/initializers
          create  config/initializers/backtrace_silencers.rb
          create  vendor/plugins
          create  vendor/plugins/.gitkeep
  6. Using rails to create user database table without sql commands.
tjyang@oi:~/demo1$ rails generate scaffold User name:string email:string
      invoke  active_record
      create    db/migrate/20110402071401_create_users.rb
      create    app/models/user.rb
      invoke    test_unit
      create      test/unit/user_test.rb
      create      test/fixtures/users.yml
       route  resources :users
      invoke  scaffold_controller
      create    app/controllers/users_controller.rb
      invoke    erb
      create      app/views/users
      create      app/views/users/index.html.erb
      create      app/views/users/edit.html.erb
      create      app/views/users/show.html.erb
      create      app/views/users/new.html.erb
      create      app/views/users/_form.html.erb
      invoke    test_unit
      create      test/functional/users_controller_test.rb
      invoke    helper
      create      app/helpers/users_helper.rb
      invoke      test_unit
      create        test/unit/helpers/users_helper_test.rb
      invoke  stylesheets
      create    public/stylesheets/scaffold.css
tjyang@oi:~/demo1$ rake db:migrate
(in /home/tjyang/demo1)
==  CreateUsers: migrating ====================================================
-- create_table(:users)
   -> 0.0020s
==  CreateUsers: migrated (0.0022s) ===========================================

  1. Verify user table really got created.
    sqlite> tjyang@oi:~/demo1$ sqlite3 ./db/development.sqlite3
    SQLite version 3.6.23
    Enter ".help" for instructions
    Enter SQL statements terminated with a ";"
    sqlite> .tables
    schema_migrations  users
    sqlite> .exit
  • No labels