RailsCasts Pro episodes are now free!

Learn more or hide this

jquadrin's Profile

GitHub User: jquadrin

Comments by

Avatar

This is an unbelievably awesome platform, very interesting..

Avatar

why does the line @haiku.add_or_update_evaluation(:votes, value, current_user) generate the error:

undefined local variable or method `user'

ruby
def vote
    value = params[:type] == "up" ? 1 : -1
    @haiku = Haiku.find(params[:id])
    @haiku.add_or_update_evaluation(:votes, value, current_user)
    redirect_to :back, notice: "Thank you for voting"
  end

application controller:

ruby
  def current_user
    @current_user ||= User.find(session[:user_id]) if session[:user_id]
  end
  helper_method :current_user

How can this be corrected?