简体   繁体   中英

Rails with activeadmin and devise - signed_in?

I have installed devise and activeadmin. When i login to activeadmin rails thinks that im also signed_in as a user on page but with no current_user value. When i go on some pages without login as user (with logged on activeadmin) statement:

<% if signed_in? %> 

is true and rails try to run script in it. How can i tell rails that activeadmin users isnt current_user for whole site?

You should tell the signed_in? method which user to look at:

on regular user pages where you do not want to be considered as signed in when you're signed in as an admin, you may want to replace

    <% if signed_in? %> 

by

    <% if user_signed_in? %> 

where user is the name of your Devise resource (if you have named it differently, replace user by the actual name (ex: if your Devise user model is EndUser, your should put end_user_signed_in?)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM