Build a Blog with Rails Part 13: Adding Scheduled Posts

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

Great series, easy to follow, even for someone new to Ruby and Rails. For a moment I got confused as some CSS styles were not working for me ("bg-gray-100" and "rounded" did, but "text-gray-900", "bg-blue-100" and "p-2" did not) - but after reviewing the CSS video I realized I started to use "rails s" again instead of "bin/dev". 🙂 Thanks for the content, good stuff.

virgo
Автор

23:25
I get it xD


Anyway thanks for great course Chris!
(I believe it's the one and the best course on whole Internet)

hardestgammaray
Автор

The desc sorting code you used, I can't seem to get it works. Some how draft which is NULL will appear first. I have to use the below code to work.

scope :sorted, -> { order("published_at DESC NULLS LAST") }

Is there a better way?

ericchua
Автор

What does this type of expression mean like *published_at.nil?* in your model helper named *draft?* ?
published_at == it is a attribute accessor for published_at field of your model?
#nil? == method which comes from where (from which class)?

olegmitnik
Автор

I am learning a lot from this tutorial, so thank you.
I am getting stuck in chapter 13 with these two statements in blog_post.rb:
scope :published, -> {where ("published_at <= ?", Time.current)}
scope :scheduled, -> { where ("published_at > ?", Time.current)}

and this is the error:
syntax error, unexpected ', ', expecting ')'
...-> {where ("published_at <= ?", Time.current)}
... ^
syntax error, unexpected ', ', expecting ')'
...-> { where ("published_at > ?", Time.current)}
... ^
Versions:
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-linux]
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-linux]
It is kind of hard to see the code, since it is quite small, so I may have made a copy mistake.
Any thoughts? I would like to continue on with the tutorial.
Thanks,
Gerry

gerryhoekema