Cannot see links visible for admins on admin account

So I was trying to hide some stuff from normal users: Helper:

def admin
  User.find(:all, :conditions => { :email => [""] })


<% if @active_user == admin %>
    <td><%= link_to raw('<i class="icon-pencil icon-white"></i>'), edit_quiz_path(quiz), :class => 'btn btn-info' %></td>
    <td><%= link_to raw('<i class="icon-trash icon-white"></i>'), quiz, method: :delete, data: { confirm: 'Pewien?' }, :class => 'btn btn-danger' %></td>
<% end %>

In the end, I logged on my admin account (with email and nothing showed.

Am I using proper function for finding the user in the db?


You could rewrite the helper method like this, so it would check the user is an admin without doing a query to the DB:

def admin?(user)
  user.present? && == ''

Even better, create the method admin? in the User class.

I changed @current_user == admin to current_user.admin? and suddenly everything is working. So in the end it was the view that was wrong.

Need Your Help

Editing row added to table with jQuery

jquery table row edit

I found this post: Editing and deleting a newly added table row using Jquery and that seemed like it was exactly what I was looking for, but I couldn't get thier suggested solution to work.

Symfony 2 functional test: authenticate user of own User class

php security testing symfony2 phpunit

As described in answer of How to use an authenticated user in a Symfony2 functional test? there is a simple solution with Symfony\Component\Security\Core\User\User.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.