# Having trouble setting up my View Page to only show Specific Data?

**URL:** <https://www.ruby-forum.com/t/having-trouble-setting-up-my-view-page-to-only-show-specific-data/238308>\
**Category:** Rails\
**Created:** [January 2, 2014, 6:24pm UTC](https://www.ruby-forum.com/t/having-trouble-setting-up-my-view-page-to-only-show-specific-data/238308 "2014-01-02T18:24:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [January 2, 2014, 6:24pm UTC](https://www.ruby-forum.com/t/having-trouble-setting-up-my-view-page-to-only-show-specific-data/238308/1 "2014-01-02T18:24:05Z")

</div>

Hello,

In my view (index.html) I have a table that calls all of my projects.  
\<% @projects.each do |project| %\>

I created 2 methods in the Model, project.late? and project.dueSoon?  
In these methods I used If Then Elsif Else Blocks to form my logic, all  
based on a bunch of my date fields which determine if the project is  
late or dueSoon.

I have also created a class that takes the Late and due soon methods and  
adds a Color-Background style if the Specific project is valid.  
\<% colorClass = project.late? ? “late” : project.dueSoon? ? “dueSoon” :  
“ok” %\>

\>\<%= link\_to project.product, project %\>

All this works great in my index View. My goal now is to create a 2nd  
View, delinquent.html.erb page that only returns the project(s) of  
Projects.project that are Late or dueSoon.

If someone could assist me with this that would be great.

Thank You.

---

<div class="post-metadata">

**Author:** ![tdd2110](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/85e7bf/32.png) [@tdd2110](https://www.ruby-forum.com/u/tdd2110)\
**Post date:** [January 3, 2014, 10:41am UTC](https://www.ruby-forum.com/t/having-trouble-setting-up-my-view-page-to-only-show-specific-data/238308/2 "2014-01-03T10:41:14Z")

</div>

I would use  
scopes[http://guides.rubyonrails.org/active\_record\_querying.html#scopes](http://guides.rubyonrails.org/active_record_querying.html#scopes)for  
late or “due soon” projects.

class Project \< ActiveRecord::Base  
scope :late, → { where(“some\_time\_attr \> ?”, Time.now) }  
end

So, then you can call the following in your Controller:

@projects = Project.late
