I set root :to => welcome#index in routes.rb. But I want after user successful login, set root_path to others. FYI : i''m using Devise. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
You could just have your welcome#index action redirect to another controller/action if the user is signed in. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/DjaHrdDldfkJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Thu, Dec 22, 2011 at 16:00, Tim Shaffer <timshaffer-BUHhN+a2lJ4@public.gmane.org> wrote:> You could just have your welcome#index action redirect to another > controller/action if the user is signed in.That will work nicely for most purposes, but also means that logged-in users can''t access the regular root page. Just have to be careful not to have anything they might need, *only* on there. -Dave -- Dave Aronson, President, Dave Aronson Software Engineering & Training Ruby on Rails (and others languages) Freelancer (NoVa, DC, or Remote) On the web: www.DaveAronson.com, www.Codosaur.us, and www.Dare2XL.com Specialization is for insects. (Heinlein) Have Pun, Will Babble! (me) -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 22 December 2011 21:08, Dave Aronson <googlegroups2dave-BRiZGj7G2yRXqviUI+FSNg@public.gmane.org> wrote:> On Thu, Dec 22, 2011 at 16:00, Tim Shaffer <timshaffer-BUHhN+a2lJ4@public.gmane.org> wrote: > >> You could just have your welcome#index action redirect to another >> controller/action if the user is signed in. > > That will work nicely for most purposes, but also means that logged-in > users can''t access the regular root page. Just have to be careful not > to have anything they might need, *only* on there.It may work better the other way around, make the default root be the page for logged in user and redirect to welcome page if not logged in. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
Thank you tim,dave,colin. I get it. but find difficult to implement it. could you guy teach me how to write the function ? I''m new to ror. Thanks. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Are you kidding me? On Dec 23, 3:18 pm, wei jack <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Thank you tim,dave,colin. > > I get it. but find difficult to implement it. > could you guy teach me how to write the function ? > I''m new to ror. > > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
Suppose you need projects#index to be visible only to logged in users. As Colin explained above, In your routes.rb put root :to => projects#index Devise provides you a method called authenticate_user! It checks if user is logged in, if not it redirects the user to login page. In the ProjectsController add a before_filter like this. class HomeController < ApplicationController before_filter :authenticate_admin! def index .... end .... end So if the user is logged in he sees the page or else he is redirected to the login page. Gautam Pai On Fri, Dec 23, 2011 at 1:43 PM, Lewisou <lewisou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Are you kidding me? > > On Dec 23, 3:18 pm, wei jack <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > > Thank you tim,dave,colin. > > > > I get it. but find difficult to implement it. > > could you guy teach me how to write the function ? > > I''m new to ror. > > > > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
You could use the devise helper methods like after_update_path_for after_sign_in_path I am not sure if this is the method''s name, please check the documentation for better understating. thanks follow this link https://github.com/plataformatec/devise/wiki/How-To:-Change-the-redirect-path-after-destroying-a-session-i.e.-signing-out 2011/12/23 Gautam Pai <gomzi.pai-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> 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-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- thiagocifani http://thiagocifani.wordpress.com/ twitter.com/thiagocifani del.icio.us/thiagocifani <http://del.icio.us/thiagocifani> -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Gautam Pai, I think can''t move authenticate_user to ProjectController because I have other controllers actions which only registered user can access. Thiagocifani, Thanks for helping me figure out to solve my problem. I tried. after_sign_in_path - redirect to a path after user success signed in. after_sign_out_path_for - redirect to a path after user signed out. I want Before user login, request localhost:3000. it will bring user to welcome#index. On welcome#index has a link go to sign in path. After user success login. localhost:3000. will bring user to projects#index and during time user still signed_in, she/he can''t access to welcome#index. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I am not understanding what you want to do! You want user log in your site twice? 2011/12/23 wei jack <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>> Gautam Pai, I think can''t move authenticate_user to ProjectController > because I have other controllers actions which only registered user can > access. > > Thiagocifani, Thanks for helping me figure out to solve my problem. > I tried. > after_sign_in_path - redirect to a path after user success signed in. > after_sign_out_path_for - redirect to a path after user signed out. > > > I want > > Before user login, request localhost:3000. > it will bring user to welcome#index. > On welcome#index has a link go to sign in path. > > After user success login. localhost:3000. > will bring user to projects#index and > during time user still signed_in, she/he can''t access to welcome#index. > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- thiagocifani http://thiagocifani.wordpress.com/ twitter.com/thiagocifani del.icio.us/thiagocifani <http://del.icio.us/thiagocifani> -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
what i want to do is like u go to facebook. Before u login www.facebook.com, u see the welcome page. After u login www.facebook.com, u see the page where all friends sharing stuffs. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Fri, Dec 23, 2011 at 13:47, wei jack <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> what i want to do is like u go to facebook. > Before u login > www.facebook.com, u see the welcome page. > After u login > www.facebook.com, u see the page where all friends sharing stuffs.But they''re using the same URL both times. It''s not a redirect, or changing the root path, but different content. You can do pretty much anything you want based on whether the user is logged in. It seems rather hackish, but you could have your controller send an entirely different set of vars and have the view use an entirely different section. You could at least keep it somewhat clean by separating the two views into partials or some such.... -Dave -- Dave Aronson, President, Dave Aronson Software Engineering and Training Ruby on Rails Freelancing (Northern Virginia, Washington DC, or Remote) DaveAronson.com, Codosaur.us, Dare2XL.com, & RecruitingRants.com (NEW!) Specialization is for insects. (Heinlein) - Have Pun, Will Babble! (me) -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
You don''t necessarily have to redirect either, you can just render a different layout if you want: http://guides.rubyonrails.org/layouts_and_rendering.html On Dec 23, 10:47 am, wei jack <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> what i want to do is like u go to facebook. > > Before u login > > www.facebook.com, u see the welcome page. > > After u login > > www.facebook.com, u see the page where all friends sharing stuffs. > > -- > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.