在概念上可以在测试方法中运行循环吗?
我想在控制器中测试一系列参数值,以确定不同的输入是否返回正确的值.
test "logged in user - add something - 0 qty" do
@app = Factory.create(:app)
(0..5).each do |t|
@qty = t
login(:user)
get :add. :id => @app.id, :qty => @qty
assert_nil(flash[:error])
assert_response :redirect
assert_redirect_to :controller => :apps, :action => :show, :id => @app.id
if @qty = 0
assert_equal(Invite.all.count, @qty + 1)
else
assert_something .........
end
end
Run Code Online (Sandbox Code Playgroud)
这样的事情.
我假设当您第一次安装heroku gem时,系统会提示您输入您的用户名/密码,它会将该用户名/密码发送到其服务器进行验证.
然后,heroku(或任何其他命令行应用程序)如何安全地在文件系统上存储该经过验证的令牌,然后在运行其他命令(如"heroku create")进行验证时将其一起传输?
我在这里使用heroku作为一个例子,因为它是我能想到的唯一一个我现在想做的事情.
我目前正在使用Rails 2.3.5,我在我的应用程序中尝试尽可能多地使用rescue_from exception.
我的ApplicationController救援现在看起来像这样:
rescue_from Acl9::AccessDenied, :with => :access_denied
rescue_from Exceptions::NotPartOfGroup, :with => :not_part_of_group
rescue_from Exceptions::SomethingWentWrong, :with => :something_went_wrong
rescue_from ActiveRecord::RecordNotFound, :with => :something_went_wrong
rescue_from ActionController::UnknownAction, :with => :something_went_wrong
rescue_from ActionController::UnknownController, :with => :something_went_wrong
rescue_from ActionController::RoutingError, :with => :something_went_wrong
Run Code Online (Sandbox Code Playgroud)
我还希望能够捕获上面没有列出的任何例外情况.有没有推荐的方式我应该写我的救援?
谢谢
我有一个模型(费用),其中包含"成本"等字段.
我想迭代我的所有费用,找到属于特定月份的所有条目的总和.
有没有办法直接在rails中做到这一点?
Expense.find(:all,:conditions => .....)
我的.irbrc位于我的〜/ .irbrc.
我注意到当我在Rails 3.x应用程序上运行'rails console'时,它说它正在寻找一个宝石.
Gems missing: no such file to load -- ap
Run Code Online (Sandbox Code Playgroud)
但如果我在rails 2.x应用程序上运行'irb'或'script/console',一切都会正常运行.
是否有另一个位置Rails 3寻找irbrc配置?
我不确定这些信息是否适用,但我在我的盒子上运行RVM(Ubuntu)