rails 页面缓存路径

如果使用默认页面缓存设置,在生产环境下,web服务器可以直接访问生成的缓存页面,不再去调用rails。

但是如果修改了默认页面缓的存放位置,又没对web服务器设置相应的规则,web服务器会因找不到页面而再次把请求转发给rails。从而使缓存变得没有意义。

mysql不能启动 Manager of pid-file quit without updating file.

启动mysql失败,提示Manager of pid-file quit without updating file.错误。从网上直接搜索错误信息,感觉出错原因及解决方案都不适用于本机的情况。

本着出错要查出其原因的原则,查看了mysql的出错日志(出错日志所在路径,请根据您自己机子的实际情况查找),发现错误信息:File ‘./mysql-bin.index’ not found (Errcode: 13),查看数据库文件,mysql-bin.index确实存在。

查看数据库文件的权限,发现全都变成了 drwx—— 2 1001 1001。突然想起之前重建过mysql用户,造成数据库文件的权限用户信息丢失。重新授权即可。

sudo chown -R  mysql var/
sudo chgrp -R  mysql var/

再次启动mysql,成功!

rspec it 描述相同也可以正常执行测试

目前实践的环境是:同样的it描述在不同的context分组中可以执行各自的测试。如果换成是rails自带的test_开头的方法测试,如果同名肯定会异常。通过这一点又证明了rspec比test更好用的另一个方面。

TDD 和 BDD

• TDD 用 test 思維,測試程式的結果
• BDD 用 spec 思維,描述程式應該有什麼行為

rspec 检查类别方法

rspec 检查类别方法

target.should be_a_kind_of(Array)
# target.class.should == Array
 
target.should be_an_instance_of(Array)
# target.class.should == Array
 
target.should response_to(:foo)
# target.response_to?(:foo).should == true

git 撤消文件修改

对于 “修复未提交文件中的错误” 时我们可以使用

git reset -- yourfile

这条命令会把文件恢复到index中的版本,而不是恢复到 HEAD revision。
当然,如果你没有把修改后的文件内容添加到index ,这个命令还是可以把你所做的修改恢复成你本地最初始的状态。

建议最好还是能看一下英文版,可以更准确的理解原著中要表达的意思。

git 恢复单个文件

如果你只是要恢复一个文件(修复未提交文件中的错误),如”hello.rb”, 你就要使用 git checkout

$ git checkout -- hello.rb

rspec controller 出错

运行 spec/controller下的测试时,如果进入到spec/controller 目录下运行相关的spec,会出现undefined method `get’ for #这样类似的错误,解决方法居然是从项目的根目录运行,即 spec spec/controller/action_controller_spec.rb。然后everything is ok.

解决方法是从一个老外的网站上找到,这里引用一下他的原话,看着这英文真是解气啊!

The problem was exactly in the path. I run my tests from spec/controllers folder where they didn’t work. From root folder everything goes right.

I found the solution, but i still don’t understand why, especially that my models tests works fine from user@user:~/application_folder/spec/models$ path

rspec in controller integration with views

If you prefer to integrate views (a la rails functional testing) you can by including
the keyword/commmand “integrate_views”.

describe ArticlesController do
  integrate_views
  ...
end

git 建立远程分支缩写

git 建立远程分支缩写

$ git remote add bob /home/bob/myrepo
$ git log -p master..bob/master

上面的命令把Bob从Alice的主分支(master)中签出后所做的修改全部显示出来。
当检查完修改后,Alice就可以把修改合并到她的主分支中。

$ git merge bob/master
Powered by WordPress | Find Wireless Deals at BestInCellPhones.com. | Thanks to iCellPhoneDeals.com Free Cell Phones, Find Highest CD Rates and Incinerador De Grasa Revisión