All threads / NoMethodError in TweetsController#create undefined method `publish_at' for nil:NilClass
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"=>""}

Join the discussion

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

Join 66,029+ 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.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2022 GoRails, LLC. All rights reserved.