I'm building a simple login screen. I'd like to return an :internal_server_error to my client if there isn't a matching user or if the password is incorrect. However, I'm getting the following missing template error:
ActionView::MissingTemplate (Missing template login/index, application/index with {:locale=>[:en], :formats=>[:json], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :coffee, :jbuilder]}. Searched in: * "C:/Shelf/myGroceryList/app/views"
What has me confused is that I have an index.html.erb template in views/login. Thoughts?
Route:
post '/login', to: 'login#show'
Controller(login_controller.rb):
class LoginController < ApplicationController
protect_from_forgery with: :null_session
def index
end
def show
username = params.values.last["email"]
password = params.values.last["password"]
loginType = params.values.last["loginType"]
if loginType == "Login"
login(username, password)
else
createNewUser(username, password)
end
end
def login(username, password)
begin
user = User.find_by(username: username)
raise(StandardError) if user.password != password
rescue
render 'index', :status => :internal_server_error
end
end
def createNewUser(username, password)
User.new(username: username, password: password)
end
end
View(index.html.erb):
<body><%= javascript_pack_tag 'login' %></body>
login#show, where is it attempting to render the index template? - max pleaner