我的create
中有Sessions controller
方法,但仍然出现此错误。它也指application/create
,可能这是我问题的根源?我的create
我也不需要application controller
方法吗?
Template is missing
Missing template sessions/create, application/create with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}. Searched in: * "/opt/csdashboard/app/views"
这是我的会话控制器:
class SessionsController < ApplicationController
def new
end
def create
dashboard_user = DashboardUsers.authenticate(params[:email], params[:password])
if dashboard_user
session[:dashboard_user_id] = dashboard_user.id
redirect_to index, :notice => 'Logged in'
else
flash.now.alert = 'Login failed'
render new
end
end
def destroy
session[:dashboard_user_id] = nil?
redirect_to root_url, :notice => 'Logged out'
end
end
以下是我的路线:
Csdashboard::Application.routes.draw do
resources :csdashboard
resources :dashboard_users
resources :sessions
get '/log_out' => 'sessions#destroy', :as => 'log_out'
get '/log_in' => 'sessions#new', :as => 'log_in'
post '/sign_up' => 'dashboard_users#new', :as => 'sign_up'
post '/dashboard_users_index' => 'dashboard_users#new'
root :to => 'dashboard_users#new'
get 'csdashboard' => 'csdashboard#index'
get '/img/:name.:ext', :to => redirect('/assets/%{name}.%{ext}')
match '/404' => 'errors#not_found'
match '/422' => 'errors#server_error'
match '/500' => 'errors#server_error'
end
应用程序控制器:
class ApplicationController < ActionController::Base
protect_from_forgery
helper_method :current_user
private
def current_user
@current_user ||= DashboardUsers.find(session[:dashboard_user_id]) if session[:dashboard_user_id]
end
end
答案 0 :(得分:0)
正在寻找具有该动作名称的template
。在操作中使用render 'new'
。