Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Template is missing

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"

like image 245
Deej Avatar asked Jun 27 '11 15:06

Deej


4 Answers

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
like image 177
felix Avatar answered Nov 15 '22 13:11

felix


In my case I had to process and render no view.

def return_payment
  # do lots of stuff

  head :ok
end
like image 39
Eduardo Xavier Avatar answered Nov 15 '22 13:11

Eduardo Xavier


I had the same problem and the reason was that I left accidentally other empty 'create' method :)

like image 26
Artur79 Avatar answered Nov 15 '22 11:11

Artur79


Generally missing template error occurs -when you don't have view file of that method of controller, or -if a method is just for calculation that does not have any view file, then you must have to render/redirect the method.

If you do not render or redirect the method, it will search for the view page of current method name (in your case it will search for create.html.erb).So, you have to render/redirect the method.

like image 39
Kishan Ku. Patel Avatar answered Nov 15 '22 12:11

Kishan Ku. Patel