Posted by Captain Zhan
Thu, 04 Oct 2007 07:35:00 GMT
到现在已经安装了好几次服务器了。总结出了一些经验,在这里和大家分享一下。
说明
我使用的linux是ubuntu 6.06 server cd版本。选第一项安装最基本的系统文件,不自动安装LAMP服务,因为ubuntu 6.06自带的apache2是2.0X的,不适合做mongrel cluster的前台,安装自带的apache2.0X之后卸载它比较麻烦,所以干脆不要自动安装LAMP服务,而手动安装apache2.2。
ubuntu 6.06 server cd的基本安装只安装系统必要文件,不安装其它服务,甚至连ssh都要手动:
sudo apt-get install ssh
安装,请大家注意要安装上ssh才能远程访问。
安装准备
加本地ubuntu源,加快下载速度。
sudo nano /etc/apt/sources.list
加入速度比较快的源,如cn99的:
deb http://ubuntu.cn99.com/ubuntu/ dapper main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ dapper-updates main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ dapper-security main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ dapper-backports main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu-cn/ dapper main restricted universe multiverse
更新系统
sudo apt-get update
sudo apt-get dist-upgrade
准备必要文件
sudo apt-get install build-essential
创建下载源码文件夹
cd ~
mkdir src
cd src
安装zlib
wget http://www.zlib.net/zlib-1.2.3.tar.gz
tar xvfz zlib-1.2.3.tar.gz
cd zlib-1.2.3/
./configure --prefix=/usr/local
make
sudo make install
cd ..
Read more...
Posted in 站长文档, Ruby on Rails | 3 comments
Posted by Captain Zhan
Thu, 06 Sep 2007 17:47:00 GMT
session:页面间的信息保存手段。
使用:
赋值
session[:person] = @user
读取
Hello #{session[:person]}
清除
session[:person] = nil
全部清除
reset_session
Ruby on Rails提供的session存储方案:
PStore (文件存储,默认方式)
ActiveRecordStore(数据库)
DRbStore
FileStore
MemoryStore
各存储方案在性能上的比较:
Ruby on Rails Session Container Performance
如何使用ActiveRecordStore(数据库)做为session存储方案
使用数据库作为session储存方案可以让网站更方便地扩展成多服务器网站。使用方法:
1. 运行 rake db:sessions:create
2. 将config/environment.rb, uncomment 中下行的注释#去除:
config.action_controller.session_store = :active_record_store
3. 运行rake db:migrate
4. 重启服务器。
linux上用来清除长时不用的session的cron命令:
$RAILS_APP_DIR/script/runner 'ActiveRecord::Base.connection.delete("DELETE FROM sessions WHERE updated_at < now() - INTERVAL 1 HOUR")
Posted in Ruby on Rails | Tags session | 6 comments
Posted by Captain Zhan
Wed, 29 Aug 2007 09:15:00 GMT
<
RailsSpace: Building a Social Networking Website with Ruby on Rails>是一本从Ruby on Rails基础教起的实例教程。但与共为实例教程的<
Agile Web Development with Rails> 相比,<RailsSpace: Building a Social Networking Website with Ruby on Rails>有着自己明显的特色。后者教授的不仅是Ruby on Rails的语言知识, 而且夹杂了更多的编程技巧和思想,我感觉更适合具有一定Ruby on Rails基础的人员,使之从“知道Ruby on Rails知识”提升到“在实战中运用Ruby on Rails"的新层次。
虽然我看过<Agile Web Development with Rails>, 但还是我在<RailsSpace: Building a Social Networking Website with Ruby on Rails>中发现的新奇的东西:
<%= link_to_unless_current "Home", :action => "index" %>
原来Rails中还有link_to_unless_current。
MySQL的发音是"My-Ess-Cue-Ell".
YAML 是 Ain't a Markup Language 的缩写。
rake db:migrate VERSION=0, 可以用来月光宝盒数据库版本。
save比save()有更重的ruby味。
在irb的console中可以使用reload!来重载被修改后的环境(我原来一直是退出来再进一次!)
Read more...
Posted in Ruby on Rails | no comments
Posted by Captain Zhan
Sat, 05 May 2007 21:35:00 GMT
Extreme Programming
Extreme Programming (or XP) is a
software engineering methodology, the most prominent of several agile software development methodologies.
Extreme Programming Explained describes Extreme Programming as being:
* An attempt to reconcile
humanity and
productivity
* A mechanism for social change
* A path to improvement
* A style of
development
* A software development discipline
Read more...
Posted in Ruby on Rails | Tags ruby on rails, software engineering, test driven development | no comments
Posted by Captain Zhan
Thu, 19 Apr 2007 11:42:00 GMT
REST (Representational State Transfer)
REST is An Architectural Style
It uses the following standards:
* HTTP
* URL
* XML/HTML/GIF/JPEG/etc (Resource Representations)
* text/xml, text/html, image/gif, image/jpeg, etc (MIME Types)
The Whole WWW is a REST system!
RESTful
Read more...
Posted in 信息处理, Ruby on Rails | no comments
Posted by Captain Zhan
Thu, 19 Apr 2007 07:44:00 GMT
By Kevin Marshall
The Basics
APIs(application programming interface)
three architectures:
Representational State Transfer (REST)
Simple Object Access Protocol (SOAP)
Extensible Markup Language Remote Procedural(XML-RPC)
(SOAP grew out of XML-RPC)
Read more...
Posted in Ruby on Rails | no comments
Posted by Captain Zhan
Wed, 04 Apr 2007 14:16:00 GMT
[ 3, 1, 7, 0 ].sort.reverse [7, 3, 1, 0]
Operator Expressions
a*b + c
(a.*(b)).+(c)
Miscellaneous Expressions
Command Expansion
`date` "Thu Aug 26 22:36:31 CDT 2004
"
`ls`.split[34] "book.out"
%x{echo "Hello there"} "Hello there
"
for i in 0..3
status = `dbmanager status id=#{i}`
# ...
end
Read more...
Posted in Ruby on Rails | no comments
Posted by Captain Zhan
Mon, 02 Apr 2007 12:17:00 GMT
De?ning a Method
Method names should begin with a lowercase letter.
Methods that act as queries are often named with a trailing
?,
Methods that are “dangerous,” or modify the receiver, may be named with a trailing
!.
methods that can be assigned to end with an equals sign (
=).
def cool_dude(arg1
="Miles", arg2="Coltrane", arg3="Roach")
"#{arg1}, #{arg2}, #{arg3}."
end
Read more...
Posted in Ruby on Rails | no comments
Posted by Captain Zhan
Wed, 21 Mar 2007 15:26:00 GMT
Regular expressions are objects of type Regexp.
create
a =
Regexp.new('^\s*[a-z]') /^\s*[a-z]/
b =
/^\s*[a-z]
/ /^\s*[a-z]/
c =
%r{^\s*[a-z]
} /^\s*[a-z]/
options:
/i case insensitive
/o only interpolate #{} blocks once
/m multiline mode - '.' will match newline
/x extended mode - whitespace is ignored
/[neus] encoding: none, EUC, UTF-8, SJIS, respectively
e.g. b =
/^\s*[a-z]
/i
match operators
=~ (positive match)
!~ (negative match)
name = "Fats Waller"
name =~ /a/ →1
name =~ /z/ → nil
/a/ =~ name →1
Read more...
Posted in Ruby on Rails | no comments
Posted by Captain Zhan
Wed, 21 Mar 2007 15:24:00 GMT
Numbers
Fixnum Bignum
123456 => 123456 # Fixnum
0d123456 => 123456&nb
Read more...
Posted in Ruby on Rails | no comments