I used a global variable in my app for passing information before. But I got a problem and thanks everyone here suggested me to store those data in session with database.
Best way of doing this is to Create a method with an argument and pass session as an argument.
session as an argument
Fro example
class User < ActiveRecord::Base def self.some_method(some_arg) User.find(some_arg) end end
from controller
User.some_method(session[:user_id])