10 months ago

让view可以调用、存取controller的method,写进application controller中

application_controller.rb
def current_user
@current_user ||= User.find_by_id!(session[:user_id])
end
helper_method :current_user

← ||=是什么? session →
 
comments powered by Disqus