This worked for me with select2 :
import select2 from "select2"
window.select2 = select2();
I had to change the timezone in config/application.rb. Rails default's timezone is UTC + 0 and my own timezone is UTC + 1. So at 8:00pm when I was trying to publish at 8:01pm, Time.current was returning 7:01pm and the guard clause "return if tweet.publish_at > Time.current" was therefore always true. Is there an easy way to manage multiple timezones ? I guess it is fine to have a timezone set in application.rb if all users are in the same timezone but background jobs would not work properly everytime a user would be in another timezone, right?
Ok, so answering to myself: this is a default implementation (discussed here: https://github.com/rails/rails/issues/34348). And the reason for this implementation is, I quote: "the reason the password is ignored for empty strings is that if a user has a form with multiple fields (including password) and they update details but don't enter the password, then we want to allow the other details to be updated without the password being effected.". Makes sense eventually :)
Yes, you can simply add this in your user model: "validates :password, presence: true". Thus, it's attaching an error "Password can't be blank" to your model's instance which is displayed on the edit view. What I don't understand is that, when you don't add this validation and submit an empty form, you do get redirected to the rootpah with the notice "password updated!", which means Current.user.update(password_params) is working. So I would expect the password to be changed to an empty string, but it is not the case. The password remains unchanged. I hope it makes sense, sorry, english is not my native language.
I may have missed something during the initial configuration but I had only set read permissions for the app so the .update(body) method was obvisously returning Twitter::Error::Unauthorized (Read-only application cannot POST.). If someone encouters the same issue, go to https://developer.twitter.com/en/portal/dashboard, find your app, in "settings" switch the app permissions to "Read, Write, and Direct Messages", then in "keys and tokens", revoke access token & secret for your test account and then disconnect and reconnect the account through your rails app running locally.
I set an alias for the auth/twitter path like so:
post 'auth/twitter', as: 'connect_twitter_account'
It's working but do you think it is ok to do so or is it a bad idea to mix this route, provided by omniauth, with the one we define ourselves?
As Dana said, this is fixed in part 40.
What I did after watching part 40 (if you want to save time):
- run "bundle add omniauth-rails_csrf_protection" in your terminal
- temporarily add "<%= button_to 'twitter', '/auth/twitter' %>" in your application.html.erb (or where you find it convenient)
- click the button, which will lead you to the desired authorization page
Editing the password with an empty string (i.e. not filling the fields and clicking right away on the submit button) doesn't throw any error, Current.user.update(password_params) returns true and the redirection is working. However, the password is not changed in the database. I don't get how it is possible that the update method returns true but at the same time, the database is not updated and there is not even a error message in the logs.