Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3219440
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:38:45+00:00 2026-05-17T15:38:45+00:00

I am trying to add a featured post feature to my Ruby on Rails

  • 0

I am trying to add a featured post feature to my Ruby on Rails Blog. So far I have added a featured_post column to my post table and it passes a 1 if the check box is selected and 0 if not.

Now I am attempting to pull out these posts by doing the following:

/views/posts/index.html.erb

  <% @featured_post.each do |post| %>
    <%= post.title %>
  <% end %>

And in the posts_controller.rb I am doing the following in the index action:

@featured_post = Post.all

Obviously this brings in all the post titles which is not what I want. I am assuming I have to add something to the controller to all for this but not sure what that is.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T15:38:46+00:00Added an answer on May 17, 2026 at 3:38 pm

    In your post model, write this

    named_scope :featured,:conditions => {:featured_post => true }
    

    write this in your controller

    @featured_posts = Post.featured
    

    and in view use this,

    <% @featured_posts.each do |post| %>
        <%= post.title %>
      <% end %>
    

    now you should get all the featured posts.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to add a feature to my app that will post a status
So currently I am trying to add a feature to a userscript I have
I´m currently trying to add the feature that is discussed here: http://blog.bmn.name/2008/03/jquery-fadeinfadeout-ie-cleartype-glitch/ A glitch
I'm trying to add the facebook connect feature to my site, I decided to
I'm trying to add an in-background alarm clock feature to an app I'm developing.
Trying to add a blank sample app for a rails tutorial to GitHub, but
I am trying to add a feature on my site where when my user
I am trying to add Thumbnails to a custom post type ('wheels') admin page,
I'm trying to use Django's annotate feature to add the count of a related
I am trying to add a feature for logging out, which is called in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.