If statement to show content in Ruby on Rails

If statement in Ruby on Rails

Here is an example of the a way to do a simple if statement in ruby on rails to show content according to user level. In this application I am using Devise which allows for that current_user and user level checks.

The if statement here, in simple terms says if current_user is logged in AND current user is an admin OR if user is logged in and the user.member.role is Tenant Coordinator.

Code:

<% if current_user && current_user.is_admin? || current_user && current_user.member.role == 'Tenant Coordinator' %>
<%= link_to ('<i class="fa fa-pencil"></i> ').html_safe,
edit_area_path(@area), :title => 'Edit Tenant Space',
:class => 'branded-color print-none float-right-until',
:style => "color: #210f5b;font-size:24pt;margin-left:20px;" %>
<% end %>