由于是1.8.x;圣经的1.9.3差太多,所以另外按1.8.X来创建hello world

第一個Hello World!!

1. 创建项目rails -d mysql first

2。创建控制器 

cd first

ruby script/generate controller hello

3.创建交互动作

vi app/controllers/hello_controller.rb 

修改为

class HelloController < ApplicationController

  def there

  end

end

4.创建对应动作的view层

vi app/views/hello/there.rhtml

<h1>Hello, World!</h1>

5.此时启动服务器

./script/server

5.前端访问

http://192.168.60.128:3000/hello/there

报错

Errno::ENOENT in HelloController#there

No such file or directory - /tmp/mysql.sock

解决: 安装mysql之后

  service mysqld start

解决办法:

ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock

遇到问题

#42000Unknown database 'first_development'

解决办法

[root@localhost /]# mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 4

Server version: 5.1.52 Qihoo.com

 

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

This software comes with ABSOLUTELY NO WARRANTY. This is free software,

and you are welcome to modify and redistribute it under the GPL v2 license

 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

 

mysql> create database first_development;

Query OK, 1 row affected (0.00 sec)

终于TMD访问成功

总结:

1.由于ruby on rails的架构,必须关联数据库,用 rails  first 创建会默认关联 sqlite库。去掉 database.yml也报错

2.用rails -d mysql first创建会在config/database.yml中写下

# MySQL.  Versions 4.1 and 5.0 are recommended.

#

# Install the MySQL driver:

#   gem install mysql

# On Mac OS X:

#   sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql

# On Mac OS X Leopard:

#   sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

#       This sets the ARCHFLAGS environment variable to your native architecture

# On Windows:

#   gem install mysql

#       Choose the win32 build.

#       Install MySQL and put its /bin directory on your path.

#

# And be sure to use new-style password hashing:

#   http://dev.mysql.com/doc/refman/5.0/en/old-client.html

development:

  adapter: mysql

  encoding: utf8

  database: first_development

  username: root

  password:

  host: localhost

 

# Warning: The database defined as "test" will be erased and

# re-generated from your development database when you run "rake".

# Do not set this db to the same as development or production.

test:

  adapter: mysql

  encoding: utf8

  database: first_test

  username: root

  password:

  host: localhost

 

production:

  adapter: mysql

  encoding: utf8

  database: first_production

  username: root

  password: 

  host: localhost

说明当前开发时使用的是development库,上线后可以改用 production 库,具体怎么设置还没学习到

最新文章

  1. 【Java EE 学习 43】【SVN版本控制工具】【CVS版本控制工具】
  2. 使用Gogs搭建Git服务器
  3. 清除MAC OS X上的流氓软件 - advance mac cleaner
  4. IE浏览器版本判断
  5. Git的一些实用操作
  6. iostat命令
  7. jquery插件 源码
  8. MONO 说谈
  9. 轻轻谈一下seaJs——模块化开发的利器
  10. DDD(领域驱动设计)理论结合实践
  11. LDAP查询实例
  12. ios 初体验&lt;UIButton 控件&gt;
  13. hdu1203 I NEED A OFFER!---概率DP(01背包)
  14. MT【247】恒成立画图像
  15. 《 Oracle查询优化改写 技巧与案例 》电子工业出版社
  16. POJ 2987 Firing【最大权闭合图-最小割】
  17. SQL类型转换和数学函数
  18. PHP 通过带SSL的SMTP 发送邮件的处理
  19. hibernate调用mysql存储过程
  20. JavaWeb学习总结(十六)Cookie保存中文内容

热门文章

  1. python爬虫实战1
  2. perl encode_utf8 和decode_utf8
  3. 2014ACM/ICPC亚洲区鞍山赛区现场赛1009Osu!
  4. 复习知识点:TabBarViewController(微信框架)
  5. LA-3135 - Argus(优先队列)
  6. [置顶] 我的GB28181标准开发里程碑——基于eXosip的IPC端与SPVMN注册成功
  7. SB中使用Autolayout设置到父视图的间距为0
  8. C#_会员管理系统:开发六(数据搜索)
  9. N皇后( DFS,推荐)
  10. Codeforces 489C Given Length and Sum of Digits...