基于ROR(ruby on Rails)的小型记账系统
2011-11-20 16:51
316 查看
前记
刚开始单位的人数比较少,记账还不是很困难,因为大家都一起吃饭,一般情况下都是平均一个价。可是后来新同事越来越多,吃饭也分成了多个小组,有人吃炒菜,有人吃面,饺子。吃炒菜还好计算,就是总消费除以人数,但是吃面和饺子就比较麻烦了,每个人的价格根据吃的量决定。人多了,算起来就复杂了,所以需要一个记账系统,让电脑来完成复杂的计算问题。
选择ROR
Rails 是基于ruby的一个web应用开发的框架,有了这个框架,开发web应用就变得非常容易,只需要针对自己的应用做一些特定的编程。rails 自带web服务器,数据库采用sqlite3。
创建depot应用
1. 安装ruby, rubygems, rails:
2. 创建depot应用:
#cd /opt/web-app/
#rails depot
开发记账系统
需求:
1. 帐号创建,删除,修改(用户名,密码,邮箱|user/new, user/del, user/edit)
2. 用户登录(admin/login)
2. 充值(可多选,每人充值一样的金额,发邮件给充值了的人|admin/charge)
3. 消费(给出总额,选择多人,取得平均消费额,减掉消费额,发邮件给相关人|admin/consume)
4. 查看余额(列出所有人的余额|admin/list_all)
开发:
1. generate controllers:
admin_controller.rb
depot> ruby script/generate controller admin login logout index consume charge list_all
users_controller.rb
depot> ruby script/generate controller user new edit del
2. views:
admin
-login.html.erb(login page for user to login)
-index.html.erb(shows the account info the logined user, also links: "logout", if he is admin, it wil also show "consume", "charge", “users", "list_all")
-list_all.html.erb(list all account infos for all users)
-consume.html.erb(input total cost, select attendees, submit)
-charge.html.erb(input charge count, select who charges, submit)
layouts
-admin.html.erb
-user.html.erb
users
- edit.html.erb
-index.html.erb
-new.html.erb
-show.html.erb
3. db tables:
users
groups
accouts
4. add sending mail functions when cosume or charge some money.
采用本机作为SMTP服务器(需要安装postfix),外网,内网邮件发送测试通过。
遇到的问题
【过程中depot.css老是不起作用,ERROR NoMethodError: private method `gsub!' called 】
To continue using Webrick, instead of switching to Mongrel, you can also
just edit line 15 of lib/ruby/1.8/webrick/htmlutils.rb to read
str = string ? string.to_s.dup : ""
The problem is that NotModified exception is getting passed to
HTMLUtils::escape as a class, rather than a string (originally raised in
HTTPServlet::DefaultFileHandler). Since the only things that can really
be HTML escaped are strings, it should be safe to always convert the
input to string.
刚开始单位的人数比较少,记账还不是很困难,因为大家都一起吃饭,一般情况下都是平均一个价。可是后来新同事越来越多,吃饭也分成了多个小组,有人吃炒菜,有人吃面,饺子。吃炒菜还好计算,就是总消费除以人数,但是吃面和饺子就比较麻烦了,每个人的价格根据吃的量决定。人多了,算起来就复杂了,所以需要一个记账系统,让电脑来完成复杂的计算问题。
选择ROR
Rails 是基于ruby的一个web应用开发的框架,有了这个框架,开发web应用就变得非常容易,只需要针对自己的应用做一些特定的编程。rails 自带web服务器,数据库采用sqlite3。
创建depot应用
1. 安装ruby, rubygems, rails:
#gem install rails --version 3.0.0
2. 创建depot应用:
#cd /opt/web-app/
#rails depot
开发记账系统
需求:
1. 帐号创建,删除,修改(用户名,密码,邮箱|user/new, user/del, user/edit)
2. 用户登录(admin/login)
2. 充值(可多选,每人充值一样的金额,发邮件给充值了的人|admin/charge)
3. 消费(给出总额,选择多人,取得平均消费额,减掉消费额,发邮件给相关人|admin/consume)
4. 查看余额(列出所有人的余额|admin/list_all)
开发:
1. generate controllers:
admin_controller.rb
depot> ruby script/generate controller admin login logout index consume charge list_all
users_controller.rb
depot> ruby script/generate controller user new edit del
2. views:
admin
-login.html.erb(login page for user to login)
-index.html.erb(shows the account info the logined user, also links: "logout", if he is admin, it wil also show "consume", "charge", “users", "list_all")
-list_all.html.erb(list all account infos for all users)
-consume.html.erb(input total cost, select attendees, submit)
-charge.html.erb(input charge count, select who charges, submit)
layouts
-admin.html.erb
-user.html.erb
users
- edit.html.erb
-index.html.erb
-new.html.erb
-show.html.erb
3. db tables:
users
groups
accouts
4. add sending mail functions when cosume or charge some money.
采用本机作为SMTP服务器(需要安装postfix),外网,内网邮件发送测试通过。
遇到的问题
【过程中depot.css老是不起作用,ERROR NoMethodError: private method `gsub!' called 】
To continue using Webrick, instead of switching to Mongrel, you can also
just edit line 15 of lib/ruby/1.8/webrick/htmlutils.rb to read
str = string ? string.to_s.dup : ""
The problem is that NotModified exception is getting passed to
HTMLUtils::escape as a class, rather than a string (originally raised in
HTTPServlet::DefaultFileHandler). Since the only things that can really
be HTML escaped are strings, it should be safe to always convert the
input to string.
相关文章推荐
- Ruby on Rails(ROR) 小结(一) 绑定controller and view
- ROR模型和数据库操作(第六章ruby on rails)
- Ruby on Rails(ROR)
- [ 接近ruby on rails]关于开发ROR project的准备工作
- RoR(Ruby on Rails)学习笔记(3)
- RoR(Ruby on Rails)学习笔记(5)
- 使用 XForms 和 Ruby on Rails 开发小型门诊管理系统,第 2 部分:实现患者信息 Xform
- [ROR] ruby on rails 命令学习
- ROR(Ruby on Rails)-图片上传
- Ruby on Rails(ROR) win安装
- Ruby on Rails(ROR)——提高rails new时bundle install运行速度
- RoR: Ruby On Rails 的 Web Service 2 使用before_invocation进行验证调用权限
- 在苹果虚拟机上跑 ROR —— Ruby on Rails On Vmware OSX 10.7.3
- [ROR] ruby on rails 入门知识
- Ubuntu 10.10下搭建ror(ruby on rails)开发环境
- RoR经典教程-VTC RUBY ON RAILS
- Radiant: 基于Ruby on Rails的内容管理系统
- Ruby on Rails(ROR)——使用sqlite3数据库
- windows下基于Ruby独立安装包+Rails一键安装包搭建RoR环境
- 10个基于 Ruby on Rails 构建的顶级站点