Notifications
You鈥檙e not receiving notifications from this thread.
Rails for Beginners Part 27: Twitter Accounts Page Discussion
This episode has been updated for Omniauth 2.0. 馃憤
Many thanks I have this doubt in episode 25 and now I know how to solve it, thanks.
How do you authorize the user to access my account all the time?
I have to authorize the user every time I log in to twitter.
Any answers are welcome!!
When I do User.last.twitter_accounts, I get this:
=> #]>
Why are the name and username nil?
Any advice is hugely appreciated :)
<ActiveRecord::Associations::CollectionProxy [#<TwitterAccount id: 1, user_id: 3, name: nil, username: nil, image: nil, token: [FILTERED]
I get this result by the way
I had the same issue. You need to request Elevated access for the Twitter API via the developer dashboard
On Rails 7 - to get my "Connect a Twitter Account" button to work correctly, I needed to use the following:
<%= button_to "Connect a Twitter account", "/auth/twitter/", method: :post, :data => { turbo: "false" }, class: "btn btn-primary"%>
I also noticed that on my Disconnect button, the confirm "Are you sure?", would not show. I'm guessing it has to do with the button_to and turbo_confirm or something? If anyone figures this out, would love a reply.
For the disconnect button on Rails 7, I used this and it's working correctly with the confirm now. Hope it helps!
<%= link_to "Disconnect", twitter_account, data: { turbo_method: :delete, turbo_confirm: 'Are you sure?' }, class: "btn btn-danger" %>
Got it to work using this
<%= button_to "Disconnect", twitter_account, method: :delete, form: { data: { turbo_confirm: 'Are you sure?' } }, class:"btn btn-outline-danger" %>
. Source is stackoverflow but unfortunately links cannot be added to the comment section so will just copy over the explanation.
`Because you are using Turbo, you need to add the data-turbo-confirm to the form itself, unlike in rails-ujs. Which you would add it to the button.
Keep in mind button_to generated a form unlike link_to`