Ruby on Rails
Friday, December 23, 2011
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@gmail.com> wrote:
Are you kidding me?
> Posted viahttp://www.ruby-forum.com/.
On Dec 23, 3:18 pm, wei jack <li...@ruby-forum.com> 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.
>
> --
--
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.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment