Ruby-on-rails – Template is missing

ruby-on-rails

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.

Template is missing

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"

Best Answer

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

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

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
Related Topic