第一次编写rails程序出现的错误

1 unknow action 

The action 'my_test' could not be found for MytestsController

在对应的MytestsController的控制器中找不到my_test这个方法,动作

2 Template is missing

找不到对应的视图,它会现找自己写的Controller对应的模板,如果找不到,

就会去找ApplicationController对应的模板,因为我们写的Controller继承了前者。

3 NoMethodError (You have anilobjectwhenyou didn't expect it!

You might have expected an instance ofArray.

The error occurredwhileevaluatingnil.each

调用方法的对象为空。这个是最常见的错误,根据错误信息可以知道,调用each方法的对象为空,只要检查each前的对象即可

nil.each

4 ActionController::RoutingError (No route matches

路径错误

5 ActionView::TemplateError (You have anilobjectwhenyou didn't expect it!

You might have expected an instance of ActiveRecord::Base.

The error occurredwhileevaluatingnil.[]) on line

与3类似,调用方法的对象为空

6 RuntimeError (Called idfornil, which would mistakenly be 4 --ifyou really wanted the id ofnil, use object_id):

find_by 必须要有查询不为空的结果,不然就报错。

7 ActionView::TemplateError (compile error

D:/cetcit/app/views/admin/data_stats/index.erb:30: syntax error, unexpected kENSURE, expecting kEND

D:/cetcit/app/views/admin/data_stats/index.erb:32: syntax error, unexpected$end, expecting kEND) on line#30 of app/views/admin/data_stats/index.erb:

使用循环语句或者控制语句时,忘记了end

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容