流水笔记一则.
我之前已在服务器配置了nginx,php,mysql等,现在先安装ruby企业版
cd /tmp
wget http://rubyforge.org/frs/download.php/71096/ruby-enterprise-1.8.7-2010.02.tar.gz
tar -xzvf ruby-enterprise-1.8.7-2010.02.tar.gz
cd ruby-enterprise-1.8.7-2010.02
./installer
然后按照提示做
阅读剩余部分...
像原来在xp下装一样
memcached.exe -d install
memcached.exe -d start
报错“ failed to install service or service already installed”
解决方法:
管理员身份安装,首先找出cmd.exe的原文件(在c:\windows\system32\cmd.exe),
右击以管理员进入,接下来的步骤就和xp安装方法一样了
利用layout可以很好实现这个需求.
在ApplicationHelper内加入如下代码:
def require_js(path)
content_for :header_js do
include_js_tag path
end
end
def require_css(path)
content_for :header_css do
include_css_tag path
end
end
def include_js_tag(path)
if not path.starts_with?("http:")
path = "/themes/#{@setting[:theme]}/javascripts/" + path
end
javascript_include_tag path
end
def include_css_tag(path)
if not path.starts_with?("http:")
path = "/themes/#{@setting[:theme]}/stylesheets/" + path
end
stylesheet_link_tag path
end
(如果你要直接在view或者layout内引入css则可以<%= include_css_tag "global.css" %>,这样生成的路径是带有皮肤目录的)
接下来,修改你的layout的head,加入如下代码:
阅读剩余部分...
posted on
January 21, 2010
发现一个很棒的插件 rails_reviewer插件
安装:
$ script/plugin install git://github.com/dsboulder/query_reviewer.git
$ rake query_reviewer:setup
完毕后重启server,页面左上角浮动一个SQL CRITICAL浮动窗口,里面记录页面加载时执行的所有SQL以及优化建议等。
强烈推荐 !!!
posted on
January 15, 2010
从ubuntu换回了win7后又慢慢开始折腾以前在本本上跑的一些LAMP网站, php和 mysql还是用以前的xampp里的,仍然可以用。
重装了 ruby 1.8.6, rails 2.3.5 等...发现运行rails网站,弹出messagebox提示找不到libmysql.dll尝试把mysql/bin里的dll来regsvr32,不可,直接拷贝到system32目录下错误没了,但打开网站仍然报错,终端显示“Mysql::Error: query: not connected...."
阅读剩余部分...
posted on
September 24, 2009
Rails使用的ActiveRecord真性感啊,see see吧
class User < ActiveRecord::Base
has_many :articles
end
class Article < ActiveRecord::Base
belongs_to :user
end
然后执行
>> Article.find(1) 会得到延迟加载user对象的sql语句。如下:
阅读剩余部分...
posted on
August 29, 2009
安装好Ruby on Rails 2.3.3后,运行简单的页面提示如下错误“The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql”
gem 了n次也不成,搞了一早上,才google到一个比较山寨的方法解决
1. download older MySQL client library, for example one from InstantRails: http://instantrails.rubyforge.org/svn/trunk/InstantRails-win/InstantRails/mysql/bin/libmySQL.dll
2. copy the downloaded file to C:\Ruby\bin (or wherever you installed Ruby)
3. restart MySQL server
另参考:http://www.ruby-forum.com/topic/160358和http://rdc.taobao.com/blog/qa/?p=523
posted on
August 21, 2009
在C#中为了提高性能使用了字符串驻留技术,而在Python中不光是字符串,连整数都有使用类似的驻留技术哦,看下面的测试:
C:\Documents and Settings\Marble Wu>python
Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> a=1
>>> b=1
>>> id(1)
10446048
>>> id(a)
10446048
>>> import sys
>>> sys.getrefcount(a)
245
>>> sys.getrefcount(b)
245
>>>
其实也很容易理解,因为在Python一切皆对象