# How to declare home page using my current setup

**URL:** <https://www.ruby-forum.com/t/how-to-declare-home-page-using-my-current-setup/131266>\
**Category:** Rails\
**Created:** [March 7, 2008, 2:34pm UTC](https://www.ruby-forum.com/t/how-to-declare-home-page-using-my-current-setup/131266 "2008-03-07T14:34:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![capslock118](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/df705f/32.png) [@capslock118](https://www.ruby-forum.com/u/capslock118)\
**Post date:** [March 7, 2008, 2:34pm UTC](https://www.ruby-forum.com/t/how-to-declare-home-page-using-my-current-setup/131266/1 "2008-03-07T14:34:44Z")

</div>

I have a database table ‘pages’ that is called for the specific pages of  
the website. Now that I am starting to implement the project I am  
looking into how I can have a home page that is called everytime just as  
the home page.

Right now I have categories table has\_many pages.

How can I come up with a solution to having a home page in the database?  
I was thinking of just creating the home page in the scaffold - then add  
a column to the table thats titled say index, then have the page I want  
as the home page to have index set to 1 and not allow scaffolds to  
change that value for any page.

The problem I see with this idea is that to call the information to the  
main page I would need to set my instance variable with a condition =\>  
"index = 1  
" or something like that. Well what would happen if a user clicked on a  
category page? With my idea i do not see how any other information would  
be called.

but I am not sure - of course, I at this point do not know how to pass  
requests i.e. when a user clicks on a category page, back to the index  
page for the view to render the new information.

any ideas?

---

<div class="post-metadata">

**Author:** ![capslock118](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/df705f/32.png) [@capslock118](https://www.ruby-forum.com/u/capslock118)\
**Post date:** [March 7, 2008, 2:45pm UTC](https://www.ruby-forum.com/t/how-to-declare-home-page-using-my-current-setup/131266/2 "2008-03-07T14:45:32Z")

</div>

i just implemented something like that. lot’s of pages, one of them the  
homepage  
i used a boolean flag column homepage in the table

when a new page is set as homepage, i simply set the old one to false:  
old\_homepage = Page.find(:first, :conditions =\> {:homepage =\> true})  
old\_homepage.update\_attribute(:homepage, false) if old\_homepage

when display it:  
@page = Page.find(:first, :conditions =\> {:homepage =\> true})
