Build a Rails application to aecept 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.
Steps (o write the program
‘Run all 4 servers ie,
Apache
Mysql
Filezila
Mercury
Now,open InstantRails-2.0-win from e:drive_ie C:\lnstantRails-2,0-win
‘Then click on I(redcolor) folder,then below window will be op
eee ei
21/05 14.2048 Instant Rais: Severs sling
21/05 1420-49 Apache : Apache por (60s used by ™(htpd exe)!
2105 14.20 49MySq Corfigution fie changed
21/08 1420.43 Apache : Configuration fle changed
| 21705 15.38.41 MySa : Unerpeced end of MS!
Now,click on I (black color near Apache )-> select rails applications > console
dow ,a command prompt (is called ruby console window) sereen will opened.
oR
ifthe I folder is not opened then goto to the toolbar lefiside down (for system) then select
rails applications > ruby console window a command prompt (is called ruby console
window) sereen will opened...
DEPARTMENT OF MCA Iv SEMESTERThen type these commands in that console window as-(note: press Enter after each
statement)
mysql -U root
create database lab14_development;
create database labl4_test;
create database lab14_production;
use labl4_development;
create table books
(id int not null auto_increment,
name varchar(80) not null,
description text not null,
price decimal(8, 2) not null,
primary key(id)
ys
Afier this Press etrl-e
rails -d mysql labl4
(vait until it completes its processes and cursor comes out)
ed labld
Now,goto C:MlnstantRails-2.0-win\mysgNbim and copy libmySQL.alt fle and paste it in
WINDOWS\system32, if the libmySOL.dll file exists replace or delete or if you
Couldnot replace or paste or delete stop all the server and paste it.
Again goto command prompt (ruby console window) and type as
ruby seript/generate seaffold book name:string deseription:text price float
{vai until it eompletes its processes and cursor comes out)
DEPARTMENT OF MCA 2 IV SEMESTERGoto browser and type in the URL as http:/flocalhost:3000/books
now you can insert books description price.
Click on NEW BOOK
er the fields
DEPARTMENT OF MCA Iv SEMESTERagain press etrlte in command prompt(ie. ruby console window) and type
ruby script/generate controller main
(vait until it completes its processes and cursor comes out)
Now,this file will generate as main_controtler.rb in
CMnstantRails-2.0 win\rails_apps\lab14\app\controllers
Now, open the file main_controller.rb and delete the conents inside the file and type this
below code and save it in C:\lnstantRails-2.0 win\rails_apps\lab1 4\app\controllers.(in the
same folder)
main controller.rh
class MainController < ApplicationController
def welcome
@num_books = Book.count
end
def result
‘@bookid = params{:sid]
DEPARTMENT OF MCA, IV SEMESTERcall, :conditions => "id = #{@bookid}")
Now.open <-2.0-win\vails apps\labld\app\views\main type and save 2 these
files.
me.rhtml
“atitle> Welcome template for books
“