Ask A Question

Notifications

You’re not receiving notifications from this thread.

NoMethodError in TweetsController#create undefined method `publish_at' for nil:NilClass

Adalberto Caldeira asked in Rails

I am new at rails and just complete Chris tutorial in gorails.com => schedule_tweets. But I could not send any tweet , I did the UTC modification for america/brasilia, when I make a schedule tweet this error is showed in my screen. I am lost. How could I try to fix it ?
after_save_commit do
if publish_at_previously_changed?
TweetJob.set(wait_until: @tweet.publish_at).perform_later(self)
end
end

Rails.root: /home/adalberto/Documents/railsForBeginners/scheduled_tweets
Application Trace | Framework Trace | Full Trace
app/models/tweet.rb:16:in block in <class:Tweet>'
app/controllers/tweets_controller.rb:15:in
create'
Request

Parameters:

{"authenticity_token"=>"[FILTERED]",
"tweet"=>{"twitter_account_id"=>"3", "body"=>"hello", "publish_at(1i)"=>"2021", "publish_at(2i)"=>"2", "publish_at(3i)"=>"18", "publish_at(4i)"=>"20", "publish_at(5i)"=>"21"},
"button"=>""}

Reply
Join the discussion
Create an account Log in

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

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

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