Forum: Ruby on Rails How to display a welcome page

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
61b70c2f195b0e669a8e25000148d9dd?d=identicon&s=25 Eden Brandeis (Guest)
on 2005-12-25 20:07
(Received via mailing list)
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
6c4800d615c28f018698f4e3d9471a08?d=identicon&s=25 Joe Tennis (Guest)
on 2005-12-25 20:55
(Received via mailing list)
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
D6d48c40f1aee60c7dbfba68770148b2?d=identicon&s=25 Anocha Yimsiriwattana (Guest)
on 2005-12-26 06:05
(Received via mailing list)
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/HowToQuick...

Best,
Tom
61b70c2f195b0e669a8e25000148d9dd?d=identicon&s=25 Eden Brandeis (Guest)
on 2005-12-26 19:25
(Received via mailing list)
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:

www.mydomain.com

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

www.mydomain.com/user/login or
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
8fd9f26b8f23d49c8a89b63f1279e24f?d=identicon&s=25 Chris Nolan.ca (Guest)
on 2005-12-26 19:31
(Received via mailing list)
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/
This topic is locked and can not be replied to.