Ruby on Rails Friday, December 23, 2011

Then do

root :to => welcome#index

move authenticate_user! from ApplicationController to ProjectsController

then when user is logged in and visits welcome#index he will be redirected to projects_url.

If user is not logged in and visits projects url hel will be redirected to login page.

Gautam Pai

On Fri, Dec 23, 2011 at 5:28 PM, wei jack <lists@ruby-forum.com> wrote:
Follow Tim solution, Now I did.

root :to => welcome#index

class ApplicationController < ActionController::Base
   before_filter :authenticate_user!, :except[:index, :show]
end

In my welcome controller index
 def index
     if user_signed_in?
       redirect_to projects_url
     end
  end


I would like to do like colin explained.

 root :to => project#index

but how to show the welcome#index as root if user not signed in ?


Gautam Pai,Thank for reply. :)
Using ur explaination.. when user not signed in.
localhost:3000 it will go to login page.

I want it go welcome#index before user choose to login.
Correct me, if I misunderstand ur explanation.

--
Posted via http://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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.


--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment