# How to display a welcome page

**URL:** <https://www.ruby-forum.com/t/how-to-display-a-welcome-page/51077>\
**Category:** Rails\
**Created:** [December 25, 2005, 8:07pm UTC](https://www.ruby-forum.com/t/how-to-display-a-welcome-page/51077 "2005-12-25T20:07:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eden\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/6de8d8/32.png) [@Eden\_B](https://www.ruby-forum.com/u/Eden_B)\
**Post date:** [December 25, 2005, 8:07pm UTC](https://www.ruby-forum.com/t/how-to-display-a-welcome-page/51077/1 "2005-12-25T20:07:17Z")

</div>

Wow, I can’t believe that after a few weeks of playing around with Rails  
I  
got stuck on something that seems like it should be really simple.

How do I display a default welcome page for visitors who are not logged  
in  
and send logged in users to the appropriate controller. I am using the  
login\_engine and the user\_engine.

The two methods I have seen looking at sample code are to stick a  
http\_refresh in public/index.html or to setup a default route to go to  
some  
action controller.

What do you suggest? Can I build a conditional route that sends them to  
a  
‘Welcome’ controller if not logged in or the “MyApp” controller if  
logged  
in? Does it make sense to build a ‘Welcome’ controller just for the  
ability  
to route for it and render content with a view even though there is no  
real  
functionality and no model?

Thanks for the advice,

Eden

---

<div class="post-metadata">

**Author:** ![Eden\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/6de8d8/32.png) [@Eden\_B](https://www.ruby-forum.com/u/Eden_B)\
**Post date:** [December 25, 2005, 8:55pm UTC](https://www.ruby-forum.com/t/how-to-display-a-welcome-page/51077/2 "2005-12-25T20:55:32Z")

</div>

I thumbed through the Agile w/ Rails book recently and it had that  
worked  
out using filters… There’s a before\_filter which let’s you establihs a  
routine to run, we’ll, before other things happed… I think putting it  
in  
your application controller gives it global access.

There may be other ways to do it - not sure.

hth,  
/Joe

---

<div class="post-metadata">

**Author:** ![Eden\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/6de8d8/32.png) [@Eden\_B](https://www.ruby-forum.com/u/Eden_B)\
**Post date:** [December 26, 2005, 6:05am UTC](https://www.ruby-forum.com/t/how-to-display-a-welcome-page/51077/3 "2005-12-26T06:05:21Z")

</div>

Joe Tennis wrote:

> I thumbed through the Agile w/ Rails book recently and it had that worked  
> out using filters… There’s a before\_filter which let’s you establihs a  
> routine to run, we’ll, before other things happed… I think putting it in  
> your application controller gives it global access.

Actually it’s the best way to do, in my opinion. Check this out!

[http://wiki.rubyonrails.com/rails/pages/HowToQuicklyDoAuthenticationWithLoginGenerator](http://wiki.rubyonrails.com/rails/pages/HowToQuicklyDoAuthenticationWithLoginGenerator)

Best,  
Tom

---

<div class="post-metadata">

**Author:** ![Eden\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/6de8d8/32.png) [@Eden\_B](https://www.ruby-forum.com/u/Eden_B)\
**Post date:** [December 26, 2005, 7:25pm UTC](https://www.ruby-forum.com/t/how-to-display-a-welcome-page/51077/4 "2005-12-26T19:25:45Z")

</div>

Joe, Tom,

Thank you both for the tips. I think I understand what you are  
suggesting  
and will probably do something like that for the overall access control  
in  
my app.

My confusion is embarrassingly much simpler.

I want a basic “Welcome to my site” page to show up at:

> **[Web Hosting, Domain Name Registration - MyDomain.com](https://www.mydomain.com)**
>
> Small business web hosting offering additional business services such as: domain name registrations, email accounts, web services, and various small business solutions.

All of the routing and filter examples I see involve sending someone to  
a  
controller like:

[www.mydomain.com/user/login](http://www.mydomain.com/user/login) or  
[www.mydomain.com/mycontroller/myaction](http://www.mydomain.com/mycontroller/myaction)

right away.

Is the best way to customize the root level content for my account to  
edit  
index.html in the public folder? Will I be able to use my layout and  
dynamic content (display whether the user is logged in or not)? When I  
delete index.html, I get an exception that the controller for “/” could  
not  
be found. Why can’t I have a top level invisible controller with an  
unseen  
index action so that I can pull in dynamic content and my site-wide  
layouts. I think this must be possible, but I am stuck for now.

Thank you again for your help,

Eden

---

<div class="post-metadata">

**Author:** ![Eden\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/6de8d8/32.png) [@Eden\_B](https://www.ruby-forum.com/u/Eden_B)\
**Post date:** [December 26, 2005, 7:31pm UTC](https://www.ruby-forum.com/t/how-to-display-a-welcome-page/51077/5 "2005-12-26T19:31:51Z")

</div>

Eden,

Take a look @ config/routes.rb

In there is an example of how to use the ‘map’ to do just that.

# You can have the root of your site routed by hooking up ‘’

# – just remember to delete public/index.html.

# map.connect ‘’, :controller =\> “welcome”

Chris Nolan.ca  
[http://kekova.ca/](http://kekova.ca/)
