undefined method `model_name' for NilClass:Class
来源:互联网 发布:中银淘宝信用卡 编辑:程序博客网 时间:2024/06/06 05:29
<%= simple_form_for @user, :url => {:action => :action_name} do |f| %><% end %>
页面加载以上代码报错如下:
undefined method `model_name' for NilClass:Class
原因是因为@user为空,改代码如下
<%= simple_form_for @user.blank? ? User.new : @user, :url => {:action => :action_name} do |f| %><% end %>
笔记
- undefined method `model_name' for NilClass:Class
- undefined method `inheritable_copy' for nil:NilClass
- NoMethodError:undefined method to_ISO8601 for nil:NilClass
- ruby on rails错误undefined method `title' for nil:NilClass
- undefined method 'before_filter' for Class
- jenkins部署业务报错undefined method `chomp' for nil:NilClass
- gem安装时出现 undefined method `size' for nil:NilClass (NoMethodError) 的解决办法
- package is corrupt, exception while verifying: undefined method `size' for nil:NilClass (NoMethodErr
- undefined method `has_attachment' for Photo:Class
- (Rails) : NoMethodError: undefined method cost' for BCrypt::Engine:Class
- undefined reference to `Class::Method()'
- rails undefined method `each’ for
- undefined reference to `vtable for class::method'--链接共享库时出现
- undefined method `devise' for User(Table doesn't exist):Class解决方法
- The method newJob(Class<QuartzTest>) is undefined for the type Test
- ruby中undefined method ‘XXX' for 问题
- undefined local variable or method `version_requirements' for #
- "The method findViewById(int) is undefined for ..."
- 当将图片文件放在与项目同级的目录下时该如何获取图片信息
- Create the struct of index page via CSS
- deep learning
- top virl 不断增长
- 推荐使用userdata和localstorage做跨浏览器本地储存,具体方案如下:
- undefined method `model_name' for NilClass:Class
- 桥接模式--1
- 代码review的心得
- android---利用反射实现的屏幕录制技术
- LVS DR备忘
- SR锁存器
- Context解析
- 桥接模式--2
- Js下拉列表操作