3
私は、アプリケーションコントローラ内にヘルパーメソッドをセットアップしました。Rails 3 helper_method
class ApplicationController < ActionController::Base
# Helpers
helper_method :current_user
# Private Methods
private
def current_user
@current_user ||= Tester.find(session[:user_id]) if session[:user_id]
end
end
は、私は、エラー、私はセッションが良いです知っている
#code
Welcome <%[email protected]_user.first_name%>
#error
undefined method `first_name' for nil:NilClass
なっビューイム内の変数をCURRENT_USERするためにアクセスしようとします。 current_userにアクセスするのは正しいですか?
ヘルプ