Pages

Wednesday, November 13, 2013

Program 12

 12.

 Build a Rails application to accept book information viz. Accession number, title, authors, edition and publisher from a web page and store the information in a database and to search for a book with the title specified by the user and to display the search results with proper headings.



C:\INSTAN~1>CD C:\instantrails


C:\instantrails>PATH C:\instantrails\ruby\bin;C:\instantrails\mysql\bin;C:\Windo
ws\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPower
Shell\v1.0\;C:\Program Files\QuickTime\QTSystem\;C:\andriod\;C:\INSTAN~1\ruby\bi
n;C:\INSTAN~1\Apache;C:\INSTAN~1\PHP

C:\instantrails>cd rails_apps

C:\instantrails\rails_apps>dir
 Volume in drive C is New Volume
 Volume Serial Number is E821-51BD

 Directory of C:\instantrails\rails_apps

11/13/2013  08:19 PM    <DIR>          .
11/13/2013  08:19 PM    <DIR>          ..
10/29/2013  01:15 PM    <DIR>          .metadata
11/13/2013  08:05 PM    <DIR>          abc
11/13/2013  08:19 PM    <DIR>          abcd
10/29/2013  01:15 PM    <DIR>          cookbook
10/29/2013  01:25 PM    <DIR>          lab12
10/29/2013  01:15 PM    <DIR>          typo-2.6.0
               0 File(s)              0 bytes
               8 Dir(s)  42,111,426,560 bytes free



C:\instantrails\rails_apps>rails -d mysql ise
      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  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/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      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/console
      create  script/destroy
      create  script/generate
      create  script/performance/benchmarker
      create  script/performance/profiler
      create  script/performance/request
      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/422.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

C:\instantrails\rails_apps>cd ise

C:\instantrails\rails_apps\ise>mysql -u root

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5 to server version: 5.0.27-community

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> create database ise_development;
Query OK, 1 row affected (0.01 sec)

mysql> create database ise_production;
Query OK, 1 row affected (0.00 sec)

mysql> create database ise_test;
Query OK, 1 row affected (0.00 sec)

mysql> use ise_development;
Database changed

mysql> create table webooks(
    -> id int not null auto_increment,
    -> title varchar(30),
    -> author varchar(30),
    -> publisher varchar(30),
    -> edition int,
    -> primary key(id));
Query OK, 0 rows affected (0.08 sec)

mysql> desc book;
+-----------+-------------+------+-----+---------+----------------+
|  Field         | Type             | Null   | Key |    Default |       Extra          |
+-----------+-------------+------+-----+---------+----------------+
| id              |  int(11)          | NO   |  PRI  | NULL    | auto_increment |
| title            | varchar(30)   | YES  |         | NULL     |                         |
| author        | varchar(30)   | YES  |         | NULL    |                         |
| publisher    | varchar(30)   | YES  |         | NULL    |                         |
| edition        | int(11)          | YES  |         | NULL    |                         |
+-----------+-------------+------+-----+---------+----------------+
5 rows in set (0.00 sec)

mysql> exit
Bye

C:\instantrails\rails_apps\ise>ruby script/generate scaffold Webook id:integer
title:string author:string publisher:string edition:integer
      exists  app/models/
      exists  app/controllers/
      exists  app/helpers/
      create  app/views/webooks
      exists  app/views/layouts/
      exists  test/functional/
      exists  test/unit/
      create  app/views/webooks/index.html.erb
      create  app/views/webooks/show.html.erb
      create  app/views/webooks/new.html.erb
      create  app/views/webooks/edit.html.erb
      create  app/views/layouts/webooks.html.erb
      create  public/stylesheets/scaffold.css
  dependency  model
      exists    app/models/
      exists    test/unit/
      exists    test/fixtures/
      create    app/models/webook.rb
      create    test/unit/webook_test.rb
      create    test/fixtures/webooks.yml
      create    db/migrate
      create    db/migrate/001_create_webooks.rb
      create  app/controllers/webooks_controller.rb
      create  test/functional/webooks_controller_test.rb
      create  app/helpers/webooks_helper.rb
       route  map.resources :webooks

C:\instantrails\rails_apps\ise>ruby script/server

=> Booting Mongrel (use 'script/server webrick' to force WEBrick)
=> Rails application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment...
** Rails loaded.
** Loading any Rails specific GemPlugins
** Signals ready.  INT => stop (no restart).
** Mongrel 1.1.2 available at 0.0.0.0:3000
** Use CTRL-C to stop.

IMP : 

White Color text indicates the code generated by the system.
RED Color indicates the command given by the user...

No comments:

Post a Comment