在我的 lib/mercury/authentication.rb 文件中,我有
module Mercury
module Authentication
def can_edit?
if user_signed_in? and current_user.role == 'admin'
true
else
#flash[:notice] = "You are not authorized to view that page."
redirect_to root_path, notice:"You are not authorized to view that page."
end
end
end
end
和 app/views/layouts/application.html.erb
<% if notice %>
<p class="alert alert-success"><%= notice %></p>
<% end %>
<% if alert %>
<p class="alert alert-danger"><%= alert %></p>
<% end %>
然而,“通知”从未出现,即使它正在与设计合作!
感谢您的任何意见!