Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在需要模型中有这个动作 check_num_reports_on_need ,我需要对其进行测试,所以我想在特定需要的终端上调用它.. 这怎么做?
打开 Rails 控制台:
$ rails c
在控制台内部加载或创建模型实例:
my_model = MyModel.create( ... )
通过在实例上调用方法开始测试该方法:
my_model.check_num_reports_on_need # => some value
更改check_num_reports_on_need方法定义中的代码后,通过调用重新加载控制台环境:
check_num_reports_on_need
reload!