Tim,
You might consider a common view with two different partials - one for
each case.
routes.rb:
map.index '/',
:controller => 'pages',
:action => 'welcome',
:id => '1-welcome-page'
controllers/pages_controller.rb:
def welcome
@page = Page.find(params[:id])
respond_to do |format|
format.html # welcome.html.erb
format.xml { render :xml => @page }
end
end
views/pages/welcome.html.erb
<p>
<b>Title:</b>
<%=h @page.title %>
</p>
<% if logged_in? %>
<%= render :partial => 'layouts/welcome_back' %>
<% else %>
<%= render :partial => 'layouts/please_login' %>
<% end %>
Rick
Rick
On Nov 28, 1:45 am, Tim Conner <[EMAIL PROTECTED]>
wrote:
> Is it possible to have to have the root url configured so that the user
> is directed to a different page depending if they are logged in or not
> whilst also keeping the url the same?
>
> E.g
> If the user is logged in, I wantwww.example.comto show the Users#show
> action
> If the user is not logged in, I wantwww.example.comto the the
> Sessions#new action
>
> At the moment I have the root url configured to be the Users#show action
> and I have a 'login_required' before filter on the Users#show action
> which redirects the user to Sessions#new if the user is not logged in.
> This works well but the URL is changed when the user is directed and so
> all nonlogged in users seewww.example.com/loginas the url when they
> come to the site. I want everybody to seewww.example.comregardless of
> whether they are logged in or not.
>
> routes.rb
> map.root :controller => 'users', :action => 'show'
> map.login '/login', :controller => 'sessions', :action => 'new'
>
> Thanks
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---