管理者権限がある場合だけリンクを表示する
link_to_ifを使ってみた。
結論:リンクにはならないけど、文字は表示されちゃう^^;(7/10追記)結構便利かも?
ink_to_ifへブロックでfalse時に表示する文言を指定ができるとのこと!
view/portal/index.html.erb
<h1>Portal#index</h1> <p>Find me in app/views/portal/index.html.erb</p> <p><%= current_user.name %>さん、ようこそ</p> <p>管理者フラグ:<%= current_user.admin %></p> <%#= link_to_if(current_user.admin? ,'管理者専用ページへ',{:controller => "portal", :action => "secret"}) %> <!-- 管理者の場合のみ表示 --> <%= link_to_if(current_user.admin? ,'管理者専用ページへ',{:controller => "portal", :action => "secret"}){''} %> <%= link_to 'ログアウト', logout_url %>