ruby on rails - Devise Giving Admin Privileges to Destroy -
just added admin model devise. on rails 4.
i give admin privileges destroy , update articles other users have created.
having trouble finding documentation on how so.
right have on index page, allows current creator destroy/edit:
<% if current_user == article.user %> <p> <%= link_to 'edit', edit_article_path(article) %> <%= link_to 'destroy', article, method: :delete, data: { confirm: 'are sure?' } %> </p> <%end%> would add here let admins able well?
also here destroy action in articles_controller:
def destroy @article = current_user.articles.find(params[:id]) @article.destroy respond_to |format| format.html { redirect_to articles_url, notice: 'article destroyed.' } format.json { head :no_content } end end thank of help! still rails newbie. tons learn. if documented somewhere please point me in direction. thanks!
here go. quite extensive documentation:
https://github.com/plataformatec/devise/blob/master/readme.md
very first steps add
before_action :authenticate_user! to controllers.
if need authorization have @ cancan:
https://github.com/ryanb/cancan
or rather https://github.com/elabs/pundit since cancan no longer maintained.
Comments
Post a Comment