All threads / Rails for Beginners Part 29: Tweets Index & New Actions Discussion

Ask A Question

Notifications

You’re not receiving notifications from this thread.

Rails for Beginners Part 29: Tweets Index & New Actions Discussion

At around 6:30 where you add the /auth/twitter/ link, the method: needs to be added as a :post correct, for OAuth 2.0?

I agree. Mine just works with "method: :post" added.

<% if Current.user.twitter_accounts.none? %>
<%= link_to "Connect your Twitter Account", "/auth/twitter",method: :post, class: "btn btn-primary" %>
<% end %>

Reply

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?

I do not know Alex, because I am new at rails , but I think for now it is a good idea.

I think that looks good, what I would suggest is auth_twitter_account instead of connect_twitter_account.

Reply

having this error now SQLite3::ConstraintException: FOREIGN KEY constraint failed

How to fix it?

Checkout the video 39 (https://gorails.com/episodes/rails-for-beginners-part-39-dependent-destroy-model-associations)

Go in the file twitter_account.rb and replace:
has_many :tweets

with:
has_many :tweets, dependent: :destroy

Reply
Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 48,086+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2021 GoRails, LLC. All rights reserved.