Elvuel

善战者无赫赫之功

  • Home
  • Atom
  • About Elvuel
« Previous 1 2 Next »

列出rails应用中所有的model

己丑[牛]年 九月初二

models = [] 
ObjectSpace.each_object(Class) do |kclass| 
 models 〈〈 kclass.to_s if kclass.ancestors.include?(ActiveRecord::Base) 
end 
 
#rails中 app/models/model*.rb,不自动装载,因而以上代码通过ObjectSpace仅能获取到部分model(如插件中使用的Model). 
 
#接下来从目录中获取 
Dir.glob(RAILS_ROOT + '/app/models/*.rb').each { |file| require fi
read more >>

Tags: rails   Posted in Ruby & Rails

ruby uninstall all gems

己丑[牛]年 五月初五

gem uninstall --a --ignore-dependencies .+


就两字:慎用

read more >>

Tags: ruby   Posted in Ruby & Rails

I18N 定制中文error message

己丑[牛]年 四月十八

使用RAILS进行开发...长话短说。(版面难看了些,将就些吧,只要内容能解决问题就好了。)

具体例子 Model: User

#先加一些验证

validates_presence_of :account #:message =〉 '这里先不写'

validates_uniqueness_of :account, :if =〉 Proc.new { |elvuel| !elvuel.account.blank?} #:message =〉 '也不写'

validates_presence_of :password

...

这

read more >>

Tags: rails i18n   Posted in Ruby & Rails

转贴_Rails2_3新特性

己丑[牛]年 三月初七

网站备案 停了几天...今天重开,很久没更新了,再不出来就要发霉了.

原文地址:http://hi.baidu.com/hlxwell/blog/item/e92011fa8fd458819e51462c.html

Rails 2.3.0今天发布了第一个RC版本,和之前版本相比它包括了大量的新特性和架构的改进,在译者看来其中一些特性更是对企业应用开发有很大帮助,比如rack中

read more >>

Tags: rails   Posted in Ruby & Rails

rails session会话过期的设定

己丑[牛]年 二月初六

rails session会话过期的处理

2009年11月11日更新

session 超时设定

ActionController::Base.session_options[:expire_after] = 20.minutes

方式一:Dynamic Session Expiration Plugin

项目目录下console

ruby script/plugin install //svn.codahale.com/dynamic_session_exp/trunk"〉http://svn.codahale.com/dynamic_session_exp/trunk

在config/environment.rb

加入CGI::S

read more >>

Tags: rails session expire   Posted in Ruby & Rails

rails无组件实现验证码

己丑[牛]年 二月初五

用RMAGICK可以方便的实现验证码,可查看RAILS上验证码实现。

不过我还是想某些情况下,不用RMAGICK,那就得另想办法实现。想到ASP的无组件验证码的实现,今天就用RAILS敲了一个。

在开始之前需要了解:

1.ASP中的ChrB在RUBY该用什么

2.如何定义ruby的多维数组

开始

在电脑上找到一个以前搞的简单的

read more >>

Tags: rails 无组件验证码   Posted in Ruby & Rails

使用Editplus 快速搭建Rails开发环境

己丑[牛]年 二月初四

引因,ELVUEL最近在使用的电脑配置比较差,使用NETBEAN的IDE很慢...

工具:EDITPLUS 3(百度,谷歌搜搜大把)

开始之前请确认已安装RUBY以及RAILS

一、到www.editplus.com下载RUBY,RHTML,YAML的语法高亮文件

http://www.editplus.com/files.html 进入OTHERS

下载后解压到EDITPLUS安装目录X:EditPlus 3STX下

二、打开EDITPLUS

工具-〉参数

read more >>

Tags: rails editplus   Posted in Ruby & Rails

Rail With SqlServer

己丑[牛]年 一月廿四

RAILS2.1.2

RUBY DBI 0.2.2 不下载0.4.0的版本(该版本没有ado.rb)

SQLSERVER2000

安装 sqlserver-adapter

gem install activerecord-sqlserver-adapter --source=http://gems.rubyonrails.org

找到sqlserver_adapter.rb 拷贝到 x:rubylibrubygems1.8gemsactiverecord-2.1.2libactive_recordconnection_adapters目录下(这个时候可以 gem uninstall 掉activerecord-sql-serveradapter)

注意

read more >>

Tags: rails sqlserver   Posted in Ruby & Rails

Ruby IO模式字符串

己丑[牛]年 一月廿一

;

模式 说明
r 只读,从文件的开头开始读取(默认)
r+ 读/写.从文件的开头开始
w 只写,将已存在的文件的长度截断为0或者为写操作创建一个新文件
w+ 读/写,将已丰在的文件的长度截断为0或者为读/写操作创建一个新文件
a 只写.如果文件存在,则从文件结尾
read more >>

Tags: ruby io   Posted in Ruby & Rails

Ruby表达式之命令展开

己丑[牛]年 一月廿二

Ruby用反引号 `或%x为前缀的分界形式括起一个字符,默认情况下将被当作底层操作系统的命令来执行.

WINDOWS下的命令 HELP ECHO...

puts`help`

puts %x{echo "elvuel"}

说明:%x分界 不仅仅可以使用{}也可以使用其它的分界如中括号[],竖线||下划线__等...

另外顺便提一下 命令的退出状态 保存在全局变量 $?中

如 : pu

read more >>

Tags: ruby   Posted in Ruby & Rails

« Previous 1 2 Next »
  • Search

  • Categories

    • Ruby & Rails
    • Jobs
    • Uncategorized
  • Recent Posts

    • Prawn使用Annotation坐...
    • ejabberd mod_archive
    • Capybara get session in ...
    • Juggernaut & Rails
    • RottenEgg发布
    • ruby rmagick 生成DM
    • ActiveResource for no r...
    • Rails生成Model文档
    • 转-Method triggers:inst...
    • 招聘-Ruby on Rails软件...
  • Links

    • RailsCasts
    • The Ruby Reflector
    • Alltop Ruby
    • Command Line Refer
    • Ruby Code Snippets
    • GitHub
    • API Dock
    • OpenSourceRails
    • RailsPlugins
    • RailsLab
    • 15DaysOfJQuery
  • Archives

    • 2012年(1)

    • 2012年01月(1)
    • 2011年(10)

    • 2011年12月(1)
    • 2011年11月(1)
    • 2011年08月(2)
    • 2011年04月(2)
    • 2011年03月(1)
    • 2011年01月(3)
    • 2010年(27)

    • 2010年12月(1)
    • 2010年11月(2)
    • 2010年10月(4)
    • 2010年09月(7)
    • 2010年08月(1)
    • 2010年07月(5)
    • 2010年06月(1)
    • 2010年04月(6)
    • 2009年(13)

    • 2009年10月(1)
    • 2009年05月(2)
    • 2009年04月(1)
    • 2009年03月(2)
    • 2009年02月(7)
    • 2008年(19)

    • 2008年08月(1)
    • 2008年07月(1)
    • 2008年06月(1)
    • 2008年05月(3)
    • 2008年04月(1)
    • 2008年03月(2)
    • 2008年02月(10)

Copyright © 2010 elvuel.com Powered by Elvuel.