文章列表
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
error_class = "fieldWithErrors"
if html_tag =~ /<(label)/
%Q{
<div class="#{error_class}">
#{html_tag}
<span class="error">#{instance.error_message.res ...
- 2009-10-30 14:43
- 浏览 739
- 评论(0)
class << Marshal
def load_with_autoload(*args)
begin
load_without_autoload(*args)
rescue [ArgumentError, NameError] => ex
msg = ex.message
if msg =~ /undefined class\/module/
mod = msg.split(' ').last
if Dependencies.load_missing_constant(s ...
- 2009-10-30 14:39
- 浏览 797
- 评论(0)
Ajax pagination
This is the most popular feature request for will_paginate library. Reasons why the core library doesn’t support this are:
pagination is a concept decoupled from HTTP
requests and rendering;
Ajax pagination is done differently across web frameworks;
Ajax is done differently a ...
- 2009-09-25 13:20
- 浏览 827
- 评论(0)
You could use migrations. But thats just another way of describing the table.
If you want another approach (defining a model and then letting the abstraction
layer create the required database), you could use datamapper instead[1].
Then, you class will look like this:
1 class Post
2 include Da ...
- 2008-09-12 17:13
- 浏览 809
- 评论(0)
mysql安装
编译源代码并安装。
groupadd mysql
useradd mysql
cd mysql_src_home
./configure --prefix=/usr/local/mysql
make
make install
scripts/mysql_install_db
chown -R root:mysql /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql/var
chgrp -R mysql /usr/local/mysql
cp support-files/my-medium.cnf /etc/my.cn ...
- 2007-10-26 09:46
- 浏览 1211
- 评论(0)
On Behalf Of Damjan Rems:
# a1=10
# r= ?('a' + '1') # ? is whatever, r should have value 10
<script type="text/javascript"></script>
some simple ways,
A. using eval
>> a1=10
=> 10
>> macro="a1+1"
=> "a1+1"
>> eval(macro)
=> 11
...
- 2007-08-29 09:41
- 浏览 875
- 评论(0)
Understanding allocate
In rare circumstances you might want to create an object without calling its constructor (bypassing initialize). For example, maybe you have an object whose state is determined entirely by its accessors; then it isn't necessary to call mew (which calls initialize) unless yo ...
- 2007-05-09 10:36
- 浏览 947
- 评论(0)
Including a Module with append_features
module MyMod def MyMod.append_features(someClass) def someClass.modmeth puts "Module (class) method" end super # This call is necessary! end def meth1 puts "Method 1" endendclas ...
- 2007-05-09 10:30
- 浏览 1202
- 评论(0)
为什么选择ferret的原因咱就不说了,废话少说
下载ferret.gem , acts_as_ferret plugin
gem : gem insatall ferret
plugin : svn://projects.jkraemer.net/acts_as_ferret/trunk/plugin/acts_as_ferret,直接check out下来放到vendor/plugin 目录下即可
现有一个model:
class Provider< ActiveRecord::Base
....... ...................
acts_as_ ...