Quantcast
Channel: Rails: Adding a "latest post" to blog - Stack Overflow
Browsing latest articles
Browse All 3 View Live

Answer by siegy22 for Rails: Adding a "latest post" to blog

Extending @oreoluwa's answer with a little more rails conventions:Your post object:class Post < ActiverRecord::Base scope :ordered, -> { order(created_at: :desc) } # or use your own column to...

View Article



Answer by oreoluwa for Rails: Adding a "latest post" to blog

You shouldn't type it on your terminal, but in the rails console. On your terminal, type rails console, when that loads up, you can then do: post = Post.lastIn order to only render for the last post,...

View Article

Rails: Adding a "latest post" to blog

Adding a "latest post" section to blogThis is my original code to show all my posts and it works great.<% @post.each do |post| %><div class="col-md-4 col-sm-6 portfolio-item"><a...

View Article
Browsing latest articles
Browse All 3 View Live




Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>