rails 学习
lao03
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
诡异的"already initialized constant OPTIONS"及解决方案
最近要为公司一个程序加数据统计代码。在Ubuntu环境下checkout下整个程序,发现无法打开server,出错信息如下:=> Booting Mongrel (use 'script/server webrick' to force WEBrick)=> Rails application starting on http://0.0.0.0:3000=> Call with ...2007-10-15 12:40:25 · 1689 阅读 · 0 评论 -
how to test gem
I wrote some gems in my project, but testing them is a big pain.Everytime I want to make sure all functions work, I need to make a test model outside gem and test there. Here is one solution:m...2009-08-31 14:09:54 · 151 阅读 · 0 评论 -
things learned from data migration
Spend a week for data migration. Here are some things I learned:1. class OldScenario < ActiveRecord::Base establish_connection configurations['old_db'] set_table_...原创 2009-08-20 13:57:32 · 135 阅读 · 0 评论 -
我的emacs配置
学习ruby on rails 两年了,期间使用过Eclipse和Netbeans,半年以前开始使用emacs。经过刚开始的不适,半年来不断到处拷代码,改配置。最近感觉逐渐使得顺手了。把配置贴出来做一个记录,也希望能对其他人有启发或者帮助 :) model:[img]http://zzhang.iteye.com/upload/attachment/131957/3cab88d...2009-08-03 15:45:05 · 131 阅读 · 0 评论 -
useful cheat sheets.
no need download cheat anymore:)in install:sudo gem install cheatuse:cheat <sheet name>see all:cheat sheetshelp:cheat cheat2009-11-11 14:40:36 · 119 阅读 · 0 评论 -
refactor according "rails best practices"
used "rails best practices" today. details see:http://github.com/flyerhzm/rails_best_practices below are the refactor advices for my app :./config/routes.rb:58 - not use default route./...2009-11-09 17:53:22 · 177 阅读 · 0 评论 -
code refactor(keep adding)
1.old codedef page_group_toolbar(page_group) c = "" case page_group.class_name when "Preparation" c << li_link_to(t("Preparation"), admin_self_study_page_groups_path(:scenario_...2009-11-05 10:20:08 · 172 阅读 · 0 评论 -
define_method with parameters
refactor below code: def preparation?(page_group) page_group.class_name == "preparation".camelize end def task_card?(page_group) page_group.class_name == "task_card".camelize...2009-11-03 18:07:05 · 127 阅读 · 0 评论 -
example how to use 'stub' and 'mock' in sepc
Use sometime to learn stub and mock.I think below is a good example: code: def create_from_content(content) page_content = PageContent.new(content) templet = page_content.temp...2009-10-16 11:58:00 · 127 阅读 · 0 评论 -
spec tips(keep adding)
1.stub meet "one to many" relationship Here is the code:describe "original_content" do it "should generate page_group's original_content" do page_group = PageGroup.create pag...2009-10-13 17:20:58 · 157 阅读 · 0 评论 -
do not rewrite exists methods
In order to name method like a pro, I create this stupid method in Page model: def to_xml(type = nil) case type when :flex # ... when nil super() endend So later when I...2009-09-20 23:30:43 · 120 阅读 · 0 评论 -
never use not + not.
A bug take a long time to find out.I had a method like: def file_not_exsit_with?(url) require 'open-uri' return open(url).read =~ /^Status: 500 Internal Server Error/ rescue puts ...2009-09-19 22:57:10 · 127 阅读 · 0 评论 -
use screen
Doing long time rake, screen is a good assistant. screen -S + name start screen with name screen -r + name resume a screenscreen -D + name detach an attached scree...2009-09-19 02:28:55 · 272 阅读 · 0 评论 -
ruby trickes(keep adding)
some ruby tricke: 1.shorter regular expressionstring = "I am strong..."puts string[/(.*?)(\.+)/, 1] # => I am strong 2.add methods to classclass String def test1 "tes...2009-09-08 12:28:08 · 173 阅读 · 0 评论
分享