Twitter Feed Rubon Rails View Javascript
Hi! After setting the twitter_account model, before accessing Ruby console and running the "User.last.twitter_accounts" command, shouldn't we run 'rails db:migrate' to actually create the table in the database? I'm asking cause I was only able to get the query to complete after running the migrate command.
Hello friends! I connected to my twitter account using the connect button but I forgot to connect in the sign_in option.
So I received this kind of error " undefined method `twitter_accounts' for nil:NilClass" because I did not make this error bypass. How should I do to send a message to remmeber the user to connect via sign_in first? It is better to use just an alert or create a controller and all the rest if I got NilClass.
Why i don't have records of twitter accounts in the database? You can see it in the image
https://ibb.co/74T6GNn
Hi, I'm getting the following error "undefined method `twitter_accounts' for nil:NilClass". i can view the twitter_account model and in the user model i have also included the following "has_many :twitter_accounts". from the rails cons the hash i can also view the details to be insterted into the db. please assist.
I've followed the updated instructions and I've run into some intermittent behavior where I get the
when (400..499) raise OAuth::Unauthorized, response response myself. The best I can determine, if I start from the Connect Twitter button and get a Rails error partway through (say because I didn't call redirect_to root_path in OmniauthCallbacksController::twitter), then refreshing the page will lead to the above Unauthorized error.
So if you're getting this error, try fixing any underlying Rails errors and then reload the home page and click the button and see if it works!
I noticed when my twitter_account was being saved to the database that most of the fields were nil.
Looking at the rails server logs, I noticed I received some information about elevated access.
It includes the message "You currently have Essential access which includes access to Twitter API v2 endpoints only. If you need access to this endpoint, you'll need to apply for Elevated access via the Developer Portal. You can learn more here: https://developer.twitter.com/en/docs/twitter-api/getting-started/about-twitter-api#v2-access-leve"
For some context -- on 4/21/2022
I created a brand new twitter account for this application.
I tied that new twitter account to a brand new developer account.
App Details: Name: @mytwitterusername Scheduled Tweets App Icon: Left it the default Description: GoRails.com Rails for Beginners Tutorial User authentication settings: OAuth 2.0: ON OAuth 1.0a: ON OAuth 2.0 Settings: Type of App = Web App OAuth 1.0a Settings: Request email from users: ON App Permissions: Read and Write Callback URI / Redirect URL: https://localhost:3000/auth/twitter/callback I had to request the new "Elevated Access" in order for my twitter_account object to contain all the requested information from the `auth` hash. To request Elevated access - https://developer.twitter.com/en/portal/products/elevated - Click the "Apply for Elevated" button. Disclaimer: I'm sharing what I did to continue onwards with the tutorial. This is by no means what you should put in your situation. I'm not responsible for your input in this request, also I'm NOT a lawyer and yada yada, essentially be honest and fill this stuff out according to your own use case. I went through their "wizard" and essentially said the following for most large paragraph entries: How will you use the Twitter API or Twitter Data? "I'm learning Ruby on Rails from Chris Oliver's Beginner Rails tutorial on GoRails.com and intend to use the Twitter API for this Scheduled Tweets application. I plan to schedule tweets to post on my own personal Twitter account for development purposes only." Are you planning to analyze Twitter Data: NO Will your App use Tweet, Retweet, Like, Follow, or Direct Message: YES *pasted explanation paragraph text from above* Do you plan to display Tweets or aggregate data about Twitter content outside Twitter? NO or YES If Yes, *pasted explanation paragraph text from above* Will your product, service, or analysis make Twitter content or derived information available to a government entity? NO NEXT, NEXT, Accept Developer Agreement. My Approval was Instant -- re-ran the process to create the twitter_account object and it successfully created. You can also verify you have Elevated access here: https://developer.twitter.com/en/portal/products
Had the same issue of the xref not populating on the table, Requested Elevated access on the app and it works. Looks like the problem is that on Twitter API version 2.0 unless you have elevated access you cannot retrieve data from the API. Wich means that rails would try to update a table with nil values.
I added a guard to make sure unauthenticated users could not trigger the OmniauthCallbacksController#twitter action
before_action :require_signin
where require_signin is a private method I defined in application_controller
When I try to connect a Twitter User from the index page, it works fine. But, when I try from the Twitter Accounts page I get an error
"NoMethodError in OmniauthCallbacksController#twitter"
"undefined method `info' for nil:NilClass"
Rails says the error is on the line
" twitter_account = Current.user.twitter_accounts.where(username: auth.info.nickname).first_or_initialize"
What am I missing?
Source: https://gorails.com/forum/rails-for-beginners-part-25-twitter-account-model-discussion
0 Response to "Twitter Feed Rubon Rails View Javascript"
Post a Comment