Q:

rails best way to display button only for admin

I have an application with Post model with associated PostsController and Admin::PostsController under the admin namespace in routes. Controllers share the same index action with controller concern, similar to this approach. I'm using a shared view partial under the shared/posts/_posts_list to list all posts on site and also in the admin dashboard. All this is working as I expected. 
I'm asking what is the best approach to add for instance: edit post button only for admin user, that view doesn't get bloated with conditionals like <% if current_user.admin? %> to display this edit button. 

A:

If you don't want to put conditionals in your view go for two
separate views (one for regular users, one for admins).
Use conditionals in view and
include necessary elements depending on is_admin?. This is the shortest way to go if the only conditional is is_admin? check, imho. If there are more conditionals (roles, etc.) you are right, this will bloat views. You can check redmine (it is a big, open source rails project) and see that it uses conditionals in views too. Check its base layout here.
You can use helpers to generate elements depending on is_admin?. Lets say you need to show menu elements in your view. You can generate menu elements in your helper. And you can call the helper from your view. Such as:

view.html.erb
<ul>
  <%= main_menu_items("main_menu", current_user) %>
</ul>

some_helper.rb
def main_menu_items(menu_name, user = current_user)
  allowed_items(menu_name, user).map { |menu_item| content_tag(:li, menu_item) }.join
end

def allowed_items(menu_name, user)
  menus = {
    main_menu: ["Menu Item 1", "Menu Item 2"],
    main_menu_admin: ["Menu Admin Item 1"]
  }
  menu_to_return = menus[menu_name.to_sym]
  menu_to_return += menus[(menu_name + "_admin").to_sym] if user.admin?
end

This is just some quick code. If you want to use it in production, you must make some heavy changes (refactoring, getting items from models, nil checks, etc).

