How to set timezone to the local in Rails?

365 views Asked by At

Now when I add a new record to my DB it show different time! How can I solve this problem and set timezone to the locale time?

I did try this in the config/application.rb:

config.active_record.default_timezone = :local

but it doesn't help me.

And also I did try the next:

def check_params
    params[:created_at] = Time.now
    permitted = params.permit(:url, :title, :description, :post_type, :category_id, :created_at)
end

But it doesn't help me too. What do you advice me to do?

1

There are 1 answers

2
Vrushali Pawar On

adding following to application.rb works

config.time_zone = 'Eastern Time (US & Canada)'
config.active_record.default_timezone = 'Eastern Time (US & Canada)'