rails3
共 5 篇文章
rails3新建项目模板
rails 新建项目可以时加 -m 参数来使用预设模板 使用前提 *nix系统 sqlite3/mysql等数据库已经安装完毕 git rails >= 3.0.4 (3.0.4修复了不能使用https模板文件的bug) 代码 rails new my_app -T -J -m https://gist.github.com/777670.txt 自动安装gem,使用devise, haml, rspec,jquery等 自动设置中文语言,设置时区 自动删除index.html等文件 配置文件是我自己使用的,可能不适合大多数人。 欢迎大家fork后修改自己的模板
2011-02-09 17:15 · rails3 · Git · MySQL · jQuery · Rails · rspec
rails中处理复数单词的pluralize方法
原帖 缘由 在日常开发中,有时候会碰到要将一些单词按照它的数量来按单复数显示 所幸rails已经考虑到了这一点,在ActionView中有一个方法 There are <%= pluralize @user.size, "user" %>. 例子 pluralize(1, 'person') # => 1 person pluralize(2, 'person') # => 2 people pluralize(3, 'person', 'users') # => 3 users pluralize(0, 'person') # => 0 people 深入研究pluralize方法: de…
2011-02-01 20:46 · rails3 · Rails
I18n的human_attribute_name方法
当使用I18n配置mode时, 可以用yml配置'zh-CN': activerecord: models: user: "用户" attributes: user: username: "用户名" email: "邮箱" password: "密码" 因此在form_for里的 f.label :username 便会自动转化为 用户名 那在其他views要使用I18n呢? 很简单, 使用 User.human_attribute_name(:username), 就可以获得 用户名
2010-07-16 18:26 · rails3 · F# · ActiveRecord
rails3beta4 + devise + cancan 打造权限管理系统(2)
现在将整个页面汉化一下 首先,我们已经在application.rb里配置了local为 zh-CN, 然后到 http://github.com/tsechingho/rails-i18n/blob/master/rails/locale/zh-CN.yml 下载已经配置好的中文包到config/locales里,这样,rails的中文化已经做好了。 接下在做devise的汉化。 devise自己有自己的i18n文件,所以我们将config/locales里的devise.en.yml重命名为devise.zh-CN.yml,将里面的英文翻译为中文即可。 接下来做view上面的汉化 首先执…
2010-07-15 14:16 · rails3 · 工作 · 配置管理 · Rails · ActiveRecord
rails3beta4 + devise + cancan 打造权限管理系统(1)
为后面的项目做准备, 先拿来练练手。 rails的环境搭建不再重复,先新建项目 rails new passport -d=postgresql 配置postgresql的帐号密码 rake db:create 启动rails, 查看http://localhost:3000, 一切正常 配置Gemfile gem 'devise', '1.1.rc2' gem 'cancan' gem 'haml' gem 'rails3-generators', :group => :development 开始安装Gem bundle install 将haml作为默认模板,编辑config/appl…
2010-07-14 18:24 · rails3 · PostgreSQL · 项目管理 · 配置管理 · Rails