> On 2015-Dec-11, at 14:58 , Jason Hsu, Ruby on High Speed Rails 
> <jhsu802...@gmail.com> wrote:
> 
> Thanks.  Yes, this was the problem.  Now I understand that this is the proper 
> procedure for logging in for functional tests.
> 
> This raises another question: Given my use of if statements in my def create 
> function, is there any point to using before_filter or before_action in the 
> controller?  The before_filter/before_action statement doesn't replace the 
> need for those if statements.

You could have a before_action that was something like:

before_action :require_admin, except: [ :index, :show ]

def require_admin
  unless admin_signed_in?
    redirect_to not_authorized_url
  end
end


> 
> On Friday, December 11, 2015 at 12:44:41 PM UTC-6, Rob Biedenharn wrote:
> 
> > On 2015-Dec-11, at 13:12 , Jason Hsu, Ruby on High Speed Rails 
> > <jhsu8...@gmail.com <javascript:>> wrote: 
> > 
> > The admin_signed_in? method comes from the Devise gem. 
> 
> Are you using the :admin scope to do the login? 
> 
> I.e., somewhere in your login_as helper there should be something like? 
> 
>         sign_in :admin, some_user_who_is_admin 
> 
> 
> -Rob
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com 
> <mailto:rubyonrails-talk+unsubscr...@googlegroups.com>.
> To post to this group, send email to rubyonrails-talk@googlegroups.com 
> <mailto:rubyonrails-talk@googlegroups.com>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/5c47366b-2641-469b-a5de-4981e95e2fcf%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/rubyonrails-talk/5c47366b-2641-469b-a5de-4981e95e2fcf%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/BB5F7462-B214-47AD-A3A9-911C0E21B7E0%40agileconsultingllc.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to