模板丢失 [英] Template is missing

查看:41
本文介绍了模板丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前正在做一个项目,遇到了一个我以前从未遇到过的问题.目前正在做一个登录注册页面,要求用户注册.我之前有一个未定义的方法`name'错误,然后意识到该方法不是名为name而是名为full_name.我已经浏览了所有文件夹以确保任何方法或属性都没有被称为name"并将其重命名为full_name".刷新浏览器后,我收到了以前从未见过的以下错误.请一些人解释一下这个错误是什么以及我如何可能去解决它.

Currently working on a project, and have encountered a problem that I have never come across before. Currently doing a login sign up page that ask the user to sign up. I had a undefined method `name'error before, and then realised that the method is not called name it was called full_name. I have gone through all the folders to ensure that any method or attribute is not called 'name' and renamed it to 'full_name. Having refreshed the browser I recieve the following error which I haven't seen before. Can some please explain what this error is and how possibly I may go about resolving it.

模板丢失

缺少模板用户/创建{:handlers=>[:erb, :rjs, :builder,:rhtml, :rxml], :formats=>[:html],:locale=>[:en, :en]} 在视图路径中"C:/Users/patterd/Documents/Project/app/views"

Missing template users/create with {:handlers=>[:erb, :rjs, :builder, :rhtml, :rxml], :formats=>[:html], :locale=>[:en, :en]} in view paths "C:/Users/patterd/Documents/Project/app/views"

推荐答案

如果您没有在控制器的 create 方法中重定向,则会发生此错误.

This error happens if you don't redirect in the create method of your controller.

您是在控制器中的 create 方法中重定向还是渲染新表单,以防出错?

Are you redirecting in the create method in the controller or rendering the new form, in case of error?

如果没有在控制器的create 方法中进行重定向,您需要创建一个名为create.html.erb 的新文件.通常,创建成功后,您会重定向到其他页面,如下所示

Without the redirection in the create method in the controller, you need to make a new file called create.html.erb. Usually, after successful creation, you redirect to some other page like shown below

def create
  # some object you want to create
  # if the object.save is fine
  #   redirect_to object
  # else
  #   render new with the errors
  # end
end

这篇关于模板丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆