first Rails Aplication

Ror First application on rails 2.0
1. rails –database mysql hello
or rails -d mysql hello
2. create manually database on mysql
or rake db:create:all
3. ruby script/generate controller say hello

4. ruby script/server
5. type on http://localhost:3000/say/hello

for cearting table
script/generate scaffold Post title:string body:text
rake db:migrate

Steps
- rails -d mysql test
-cd test
—-manuially set the dtabase usernamr and pwd in database.yml file
-rake db:create:all
-ruby script/server (starting the server)
-ruby script/generate scaffold Movie title:string (for table cration)
-rake db:migrate

==for mongrel server
service mongrel_cluster restart
script/server –help
service nginx start

for including file
rendre:partial “path”;
render(:partial => ‘/controls/footer’)

for mongrel server steps

==start
1. copy mongrel_cluster.yml into config
changes that
2. insert some code in etc/ngix/*.conf
in that
upstream hello.rajesh {
server 127.0.0.1:8005;
}
and
server {
listen       81;
server_name  hello.rajesh;

root /sites/hello/public;

#charset koi8-r;

access_log  /var/log/nginx/hello.access.log  main;

location ~ ^/$ {
if (-f /index.html){
rewrite (.*) /index.html last;
}
proxy_pass  http://hello.rajesh;
}

location / {
if (!-f $request_filename.html) {
proxy_pass  http://hello.rajesh;
}
rewrite (.*) $1.html last;
}

location ~ .html {
root /sites/hello/public;
}

location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|mov)$ {
root /sites/hello/public;
}

location / {
proxy_pass  http://hello.rajesh;
proxy_redirect     off;
proxy_set_header   Host             $host;
proxy_set_header   X-Real-IP        $remote_addr;
proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
}

}

3. ln -s /sites/hello/config/mongrel_cluster.yml /etc/mongrel_cluster/hello.yml
4. chown -R mongrel:mongrel /sites/hello
==end
for creating only model and table
ruby script/generate model images_imagecategories image_id:integer imagecategories_id:integer
ruby script/generate model imagecategories_images images_id:integer imagecategories_id:integer

Leave a Reply