ruby on rails - What is the accepted way for admin-only tasks -


i'm not using devise learning purposes. want admins able access admin-only page.

i've created admin attribute boolean type , default value of false. can check if admin current_user.admin?.

i doing admin check like

before_action :admin_check, only: :show  def admin_check   redirect_to(root_url) unless current_user.admin? end 

safe in terms of security?

yes, looks safe me if remove only: :show part. want protect other actions well, guess...

also, assume unprivileged user has no way of reaching controller through normal navigation, i'd invalidate session, in case.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -