We will need roles and policies to determine which users are allowed to create, edit, and delete posts. This would separate authors from commentors.
The easiest solution would be to have a column on the users table called 'admin' with a boolean value. This could then be checked with if user.admin? in our views to determine if create/update/update buttons/options are shown.
I've used the Pundit gem, exactly once, which is made for the purpose of setting policies. Other popular ones I have not used are cancancan and authority.
We could also discuss whether an author's post is editable only by them or by any admin, which is generally pretty easy to do as well if user.admin? && (post.user == current_user) ...
We will need roles and policies to determine which users are allowed to create, edit, and delete posts. This would separate authors from commentors.
The easiest solution would be to have a column on the users table called 'admin' with a boolean value. This could then be checked with
if user.admin?
in our views to determine if create/update/update buttons/options are shown.I've used the Pundit gem, exactly once, which is made for the purpose of setting policies. Other popular ones I have not used are cancancan and authority.
We could also discuss whether an author's post is editable only by them or by any admin, which is generally pretty easy to do as well
if user.admin? && (post.user == current_user)
...