I’m new to RoR and I’m awfully confused on how to retrieve data from
sessions. I do know session variables are stored in a hash.
Anyway, I have two models - Note and User
In User, I have a method called login that populates session[:user] –
I also got fedup, and tried storing just the id of the user in
In Note, I want to retreive the ID of the user who is logged in.
Forgive me if what I’m doing is stupid, but I always get the error:
You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.
Here’s my code in note.rb
class Note < ActiveRecord::Base
temp_email = @session[:user_email]
temp = User.get_id(temp_email)
Note.find_by_sql [“SELECT * FROM notes WHERE user_owner = ?”, temp]
Please help me