0
我有一個非常令人沮喪的問題。問題與視圖helper_methods rails
我不能叫從我rails.This意見任何輔助方法,是我:
ApplicationController.rb
class ApplicationController < ActionController::Base
protect_from_forgery
def current_user
@current_user ||= User.find(session[:user_id]) if session[:user_id]
end
helper_method :current_user
helper_method :all
end
/app/views/welcome/_navi_bar.haml:
%ul.nav.nav-pills.pull-right
%li.pull-right
- if current_user
%a.btn-small{"data-toggle" => "modal", :href => log_out_path, :role => "button"}
%i.icon-user.icon-white
%strong
Log Out
- else
%a.btn-small{"data-toggle" => "modal", :href => "#LoginBox", :role => "button"}
%i.icon-user.icon-white
%strong
Login
這是我得到的錯誤:
undefined local variable or method `current_user' for #<#<Class:0x007ff0a0544668>:0x007ff0a05414b8>
我真的不明白問題所在。請幫忙 !
雖然我不認爲它會導致問題,我建議刪除不必要的'是helper_method:所有'線。 – Domon
@Domon沒有幫助:( –