0

I'm setting a timezone for the users using ENV["TZ"] = time_zone where time_zone is that user time zone.I also have a column in table named 'time_zone' where that user's timezone is saved.
Now i want to retrieve the event of that users in his time zone.
To retrieve my code in the model:

  def set_timezone
   Time.zone = current_user.time_zone || "Asia/Kolkata"
  end 

My controller:

before_filter :set_timezone

But i'm getting this error undefined local variable or method 'set_timezone' for SchedulersController:0x533fa78
Any Idea what could be the issue?

Sachin Prasad
  • 5,365
  • 12
  • 54
  • 101

1 Answers1

1

You can also pass a closure/block as an argument to before_filter, like this:

before_filter do
  Time.zone = current_user.time_zone || "Asia/Kolkata"
end
Dan K.K.
  • 5,915
  • 2
  • 28
  • 34