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 9 Next »

  1. install ruby
  2. "gem update --system" to update to latest gem tool.
    1. If behind firewall, "gem update --http-proxy http://firewall.test.net:portnumber --system"
  3. Run "gem install rails -v 3.0.5" to install rails-3.0.5.
  4. Install sqlite3 so that we have a database backend for testing.
    1. "gem install sqlite3" to kickoff a build that need gcc compiler installed.
  5. A quick check of installed Ruby stuff.
    tjyang@oi:~$ ruby -v
    ruby 1.8.7 (2009-06-12 patchlevel 174) [i386-solaris2.11]
    tjyang@oi:~$ gem -v
    1.6.2
    tjyang@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
      - RUBYGEMS PLATFORMS:
        - 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
      - GEM CONFIGURATION:
         - :update_sources => true
         - :verbose => true
         - :benchmark => false
         - :backtrace => false
         - :bulk_threshold => 1000
      - REMOTE SOURCES:
         - http://rubygems.org/
    tjyang@oi:~/demo1$ rails -v
    Rails 3.0.5
    tjyang@oi:~$uname -a
    SunOS oi 5.11 oi_148 i86pc i386 i86pc
    oi@oi:~$
    
  6. Create a test rails app "demo1"
    tjyang@oi:~$ rails new demo1
          create
          create  README
          create  Rakefile
          create  config.ru
          create  .gitignore
          create  Gemfile
          create  app
          create  app/controllers/application_controller.rb
          create  app/helpers/application_helper.rb
     <snip>
          create  config/environments/development.rb
          create  config/environments/production.rb
          create  config/environments/test.rb
          create  config/initializers
          create  config/initializers/backtrace_silencers.rb
       <snip>
          create  vendor/plugins
          create  vendor/plugins/.gitkeep
    tjyang@oi:~$
    
  7. 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) ===========================================
    
    tjyang@oi:~/demo1$
    
  8. 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
    tjyang@oi:~/demo1$
    
  9. startup demo1 rails application
    tjyang@oi:~/demo1$ rails s
    => Booting WEBrick
    => Rails 3.0.5 application starting in development on http://0.0.0.0:3000
    => Call with -d to detach
    => Ctrl-C to shutdown server
    [2011-04-02 02:23:50] INFO  WEBrick 1.3.1
    [2011-04-02 02:23:50] INFO  ruby 1.8.7 (2009-06-12) [i386-solaris2.11]
    [2011-04-02 02:23:51] INFO  WEBrick::HTTPServer#start: pid=48 port=3000
    
    
    Started GET "/users" for 192.168.1.204 at Sat Apr 02 02:25:53 -0500 2011
      Processing by UsersController#index as HTML
      User Load (1.0ms)  SELECT "users".* FROM "users"
    Rendered users/index.html.erb within layouts/application (4.3ms)
    Completed 200 OK in 58ms (Views: 11.0ms | ActiveRecord: 1.0ms)
    
    
    Started GET "/rails/info/properties" for 192.168.1.204 at Sat Apr 02 02:27:06 -0500 2011
      Processing by Rails::InfoController#properties as
      SQL (0.5ms)   SELECT name
     FROM sqlite_master
     WHERE type = 'table' AND NOT name = 'sqlite_sequence'
      SQL (0.2ms)   SELECT name
     FROM sqlite_master
     WHERE type = 'table' AND NOT name = 'sqlite_sequence'
    
      SQL (0.1ms)  SELECT "schema_migrations"."version" FROM "schema_migrations"
    Rendered inline template (0.3ms)
    Completed 200 OK in 29ms (Views: 1.4ms | ActiveRecord: 0.8ms)
    
    
    Started GET "/users" for 192.168.1.204 at Sat Apr 02 02:28:05 -0500 2011
      Processing by UsersController#index as HTML
      User Load (0.5ms)  SELECT "users".* FROM "users"
    Rendered users/index.html.erb within layouts/application (3.1ms)
    Completed 200 OK in 14ms (Views: 9.0ms | ActiveRecord: 0.5ms)
    
    
  10. See it from Chrome browser.

  1. See users listing

  • No labels